Created
February 13, 2024 14:07
-
-
Save Moderrek/aef5fc81a337d5c75db8a38a1519803f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
bool is_prime(unsigned long long n) { | |
if (n <= 1) return false; | |
if (n == 2) return true; | |
if (n % 2 == 0) return false; | |
for (int i = 3; i * i <= n; i += 2) | |
if (n % i == 0) return false; | |
return true; | |
} | |
int main() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(nullptr); | |
std::cout.tie(nullptr); | |
unsigned long long n = 0; | |
std::cin >> n; | |
std::cout << (is_prime(n) ? "true" : "false") << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment