Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 #include <stdio.h>
- 2 int main(void)
- 3 {
- 4 unsigned int number_of_primes=0, test_int, latest_prime, div, input;
- 5 _Bool isPrime;
- 6 #define TRUE 1
- 7 #define FALSE 0
- 8
- 9 test_int = 5;
- 10 div = 2;
- 11 isPrime = TRUE;
- 12
- 13
- 14 printf("For which prime number do you want to know the value?\n");
- 15 scanf("%u", &input);
- 16
- 17 do
- 18 {
- 19 while(div < test_int)
- 20 {
- 21 if(test_int%div == 0)
- 22 {
- 23 isPrime = FALSE;
- 24 break;
- 25 }
- 26 div++;
- 27 }
- 28 if(isPrime == TRUE)
- 29 {
- 30 number_of_primes++;
- 31 latest_prime = test_int;
- 32 }
- 33 test_int++;
- 34 }
- 35 while(number_of_primes < input);
- 36
- 37
- 38 printf("Prime = %u\n", latest_prime);
- 39
- 40 return 0;
- 41 }
- ~
- ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement