Advertisement
rootuss

faktoryzacja

Jan 30th, 2017
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. bool czypierwsza (int xx)
  6. {
  7.     for( int i=2;i<xx;i++)
  8.     {
  9.         if(xx%i==0) return false;
  10.         return true;
  11.     }
  12. }
  13.  
  14.  
  15. int main()
  16. {
  17.     int x;
  18.  
  19.     cout << "Podaj liczbe do faktoryzacji: " ;
  20.     cin>> x;
  21.  
  22.     int i=2;
  23.     do
  24.     {
  25.         while(x%i==0)
  26.         {
  27.             x=x/i;
  28.             cout<<i<<endl;
  29.  
  30.  
  31.         }
  32.         i++;
  33.  
  34.         while(czypierwsza(i)==false)
  35.             {
  36.                 i++;
  37.             }
  38.  
  39.  
  40.     }
  41.  
  42.     while(x>1);
  43.  
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement