Advertisement
Guest User

find prime factors

a guest
Feb 17th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. void factors(long long n)
  2. {
  3.     long long z = 2;
  4.     while ( (z * z) <= n )
  5.     {
  6.         if ( (n % z) == 0 )
  7.         {
  8.             cout << z << endl;
  9.             n /= z;
  10.            
  11.         } else
  12.         {
  13.             z++;
  14.         }
  15.     }
  16.     if (n > 1)
  17.     {
  18.         cout << n << endl;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement