Created
March 23, 2022 04:16
-
-
Save DJmong/98edffbdcc63a252c4d1a16d990abd8c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 isPrime(const int &num) | |
| { | |
| if(num < 2) return false; | |
| for(int i = 2; i*i <= num; ++i) | |
| { | |
| if(num % i == 0) return false; | |
| } | |
| return true; | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| for(int i = 0; i < 100; ++i) | |
| { | |
| if(isPrime(i)) | |
| { | |
| std::cout << i << std::endl; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment