Skip to content

Instantly share code, notes, and snippets.

@maksadbek
Created September 23, 2013 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksadbek/6667818 to your computer and use it in GitHub Desktop.
Save maksadbek/6667818 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
using namespace std;
int multi(int x, int y){
if(y==0)
return 0;
int z = multi(x, y/2);
if(y%2 == 0)
return 2*z;
else
return x+2*z;
}
int display(int x){
if(x == 0)
return 0;
cout<< display(x-1)<<",";
if(x%2 == 0)
return x;
else
return display(x+1);
}
int main(){
cout<<multi(10,10)<<endl;
display(100);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment