pranjal1805

Q6

May 15th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. # include <stdio.h>
  2. # include <math.h>
  3.  
  4. void primeFactors(int n);
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     printf("number de do bhaiyma plis. UwU");
  10.     scanf("%d",&n);
  11.     primeFactors(n);
  12.     return 0;
  13. }
  14.  
  15. void primeFactors(int n)
  16. {
  17.    
  18.     while (n%2 == 0)
  19.     {
  20.         printf("%d ", 2);
  21.         n = n/2;
  22.     }
  23.  
  24.     for (int i = 3; i <= sqrt(n); i = i+2)
  25.     {
  26.        
  27.         while (n%i == 0)
  28.         {
  29.             printf("%d ", i);
  30.             n = n/i;
  31.         }
  32.     }
  33.  
  34.    
  35.     if (n > 2)
  36.         printf ("%d ", n);
  37. }
  38. //gcc Q6.c -o Q6 -lm
  39. // ./Q6
  40.  
Advertisement
Add Comment
Please, Sign In to add comment