Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //números primos
  2. //indica o primo e os anteriores primos
  3.  
  4. #include<stdio.h>
  5. #include<stdbool.h>
  6. #include<math.h>
  7.  
  8.  
  9. bool primo(int num)
  10. { int i, primo=0;
  11.  
  12. for (i=2;i<=num;i++)
  13. {
  14. if(num%i==0)
  15. {
  16. primo++;
  17. }
  18. }
  19. return (primo==1);
  20.  
  21. }
  22.  
  23. int proximop(int n1)
  24. {
  25. for(int a=(1*(pow(10,n1))-1);a>=primo(a);a--)
  26. {
  27. if(primo(a))
  28. {
  29. printf("%d\n",a);
  30. break;
  31. }
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37. int i, n1;
  38. bool verdadeiro=0;
  39.  
  40. printf("Informe um número:");
  41. scanf("%d",&n1);
  42. proximop(n1);
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement