Created
September 23, 2013 08:20
-
-
Save maksadbek/6667818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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