Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <stdbool.h>
- #define FINAL_NUMER 5 * pow(10, 2)
- int main()
- {
- bool isPrime;
- for(int number = 3; number < FINAL_NUMER; number++)
- // Runs from 0 to (5 E+50)
- {
- isPrime = true;
- for(int i = 2; i <= sqrt(number); i++)
- // Runs from 2 to the square of the parameter
- {
- if ((number % i) == 0) // If it finds a divisor it returns false
- isPrime = false;
- }
- // If prime was not changed
- if(isPrime)
- printf("Prime found: %d\n", number);
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement