Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int cmmdc(int a,int b)
- {
- int r=0;
- while(b)
- {
- r = a % b;
- a = b;
- b = r;
- }
- return a;
- }
- int main()
- {
- int a, b, p = 2;
- cin >> a >> b;
- while(a)
- {
- while(1.0/p > 1.0*a/b)
- p++;
- cout << p << " ";
- a = a * p - b;
- if(a)
- {
- b = b * p;
- int d = cmmdc(a,b);
- a = a/d;
- b = b/d;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement