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, test_int, latest_prime, div, input;
- 5 _Bool isPrime;
- 6 #define TRUE 1
- 7 #define FALSE 0
- 8
- 9 test_int = 1;
- 10 number_of_primes = 0;
- 11
- 12 printf("For which prime number do you want to know the value?\n");
- 13 scanf("%u", &input);
- 14
- 15 do
- 16 {
- 17 test_int++;
- 18 isPrime = TRUE;
- 19 for(div=2; div < test_int; div++)
- 20 {
- 21 if(test_int%div == 0)
- 22 {
- 23 isPrime = FALSE;
- 24 break;
- 25 }
- 26 }
- 27 if(isPrime == TRUE)
- 28 {
- 29 number_of_primes++;
- 30 latest_prime = test_int;
- 31 }
- 32 }
- 33 while(number_of_primes < input);
- 34
- 35
- 36 printf("That Prime Number = %u\n", latest_prime);
- 37
- 38 return 0;
- 39 }
Add Comment
Please, Sign In to add comment