//find wheather a number is in the form of 3pow(n)
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<math.h>
void recur(int);
int i=1,n;
void main()
{ clrscr();
// extern int n;
cout<<"enter the number: ";
cin>>n;
recur(3);
}
void recur(int x)
{ if(x==n)
{ cout<<"number is multiple";
getch();
exit(0);
}
if(x>n)
{ cout<<"number is not multiple";
getch();
exit(0);
}
else
{ recur(pow(3,++i));
}
}
- Upinder Singh Dhami
- Bangalore, Karnataka, India
- Extending one hand to help someone has more value rather than joining two hands for prayer
write a program to check whether the given number was of the form 3^n. ( i.e. 3 to the power n).
Wednesday, February 3, 2010Posted by Upinder Singh Dhami at Wednesday, February 03, 2010 2 comments
Subscribe to:
Posts (Atom)