/*PLEASE READ: *When you are executing the code *Please keep in mind that factorial *of integers grow explosively *so an integer variable is unable to *store factorial of a number larger *than 16, if you need to deal with larger *numbers change the function make it *double fact(double) * */ #include #include #include using namespace std; int fact(int); //exp is same as pow, I change the name //because pow is a library function //available in math header file double exp(double,int); double mult(double,double); int gcd(int,int); //The name is change to make a distinction //from strlen which is already difined //in int strlength(char*,int); int palindrome(char*,int); //A function with two base cases //following function returns the //nth element in a fibonacci series int fibonacci(int); int main(){ int x,y; char s[50]; cout<<"Enter two positive integers: "; cin>>x>>y; cout<<"Factorial of "<y?x:y,x>y?y:x) <>s; cout<<"The length of the string is " <0) return base*exp(base,pow-1); //Now let's take care of negative power else return (1/base)*exp(base,pow+1); } int gcd(int big, int small){ if(big%small==0) return small; else return gcd(small,big%small); } int strlength(char *s,int index){ if(s[index]=='\0') return 0; else return 1+strlength(s,index+1); } int palindrome(char* s, int index){ if(index == (strlen(s)/2)) return 1; else if(s[index] != s[strlen(s)-1-index]) return 0; else return palindrome(s,index+1); } int fibonacci(int n){ if(n==0) return 0; else if(n==1) return 1; else return fibonacci(n-2)+fibonacci(n-1); }