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, 2010

//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));
    }
}