Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cassert>
- using namespace std;
- int gcd(int a, int b)
- {
- // Everything divides 0
- if (a == 0 || b == 0)
- return 0;
- // Base case
- if (a == b)
- return a;
- // a is greater
- if (a > b)
- return gcd(a-b, b);
- return gcd(a, b-a);
- }
- // Function to return LCM of two numbers
- int lcm(int a, int b)
- {
- return (a*b)/gcd(a, b);
- }
- int main(){
- int x,y,wx,wy;
- cin >> x >> y;
- assert(x>0 && y>0);
- wx = x;
- assert(wx==x);
- wy = y;
- assert(wy==y);
- //NIEZMIENNIK
- while(wx!=wy){
- assert(wx!=wy);
- if (wx>wy){
- assert(wx!=wy && wx>wy);
- assert(wy!=wy+y);
- wy = wy + y;
- }
- else{
- assert(wx<wy && wx!=wx+x);
- wx = wx + x;
- }
- }
- // assert(wx==nww(x,y));
- cout << wx << endl;
- cout << lcm(2,3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement