Advertisement
Slyfoxx724

final

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