Advertisement
Imran1107048

1(a)

Oct 29th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include<stdbool.h>
  4.  
  5. bool Perplexing_Primes(int n)
  6. {
  7. if(n<=1)
  8. return false;
  9. if(n==2)
  10. return true;
  11. if(n>2 && n%2==0)
  12. return false;
  13. int div = sqrt(n);
  14. for(int i=3;i<=div;i+=2)
  15. if(n%i==0)
  16. return false;
  17. return true;
  18. }
  19.  
  20. void Multiplicated_Value(int n)
  21. {
  22. while(n%2 == 0){
  23. printf("2 ");
  24. n/=2;
  25. }
  26. for(int i= 3; i<=sqrt(n);i+=2){
  27. while(n%i==0){
  28. printf("%d ",i);
  29. n/=i;
  30. }
  31. }
  32. if(n>2)
  33. printf("%d ",n);
  34. printf("\n");
  35. }
  36.  
  37. int main()
  38. {
  39. int n = (55 % 5) + 31;
  40. bool arr[n+1];
  41. if(Perplexing_Primes(n)){
  42. printf("%d is a prime!\n",n);
  43. }
  44. else{
  45. Multiplicated_Value(n);
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement