Welcome to StackEdit! Hey! I’m your first Markdown document in StackEdit 1 . Don’t delete me, I’m very helpful! I can be recovered anyway in the Utils tab of the Settings dialog. Documents StackEdit stores your documents in your browser, which means all your documents are automatically saved locally and are accessible offline! Note: StackEdit is accessible offline after the application has been loaded for the first time. Your local documents are not shared between different browsers or computers. Clearing your browser’s data may delete all your local documents! Make sure your documents are synchronized with Google Drive or Dropbox (check out the Synchronization section). Create a document The document panel is accessible using the button in the navigation bar. You can create a new document by clicking New document in the document panel. Switch to another document All your local documents are listed in the document panel. You can switch from one to anoth...
Đề bài: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Tức là tìm ước số nguyên tố lớn nhất của 600851475413. Bài này thì đương nhiên là quá dễ, tuy nhiên nếu viết bằng C++ thì cần chú ý là không thể sử dụng các kiểu cơ bản như long , vì sẽ bị tràn số. Sử dụng kiểu long long int , và chú ý là thêm LL vào sau giá trị của biến có kiểu long long int . Mã nguồn được viết và biên dịch bởi Code:Blocks 8.02, Windows XP. #include #include bool check_prime (long long int a) { if (a==2) return true; for (long long int i = 2; i if (a % i == 0) return false; } return true; } int main() { long long int n = 600851475143LL; long long int s = long(sqrt(n)); for (long long int i = s; i >= 2; i--) { if ((n % i == 0) && check_prime(i)) { cout break; } } }