I'm facing some problems.. Its very basic but i cant seems to remember how to go abt doing it...
Im supposed to input in a value
if it is 1, then im supposed to stop the program,
if n is odd, then n=n*3+1,
else n=n/2
What ive written is
int n;
cin>>n;
if (n==1)
{
cout<<n<<endl;
}
else if (n==??) ---> I'm supposed to write this as 'if n is an odd number, answer will be as follows..
{
n = 3*n + 1;
}
else
{
n = n/2;
}
cout<<n<<endl;
I;m not sure how do i do the ODD part.. Can anyone kindly help me in this.. Thank u..
Im supposed to input in a value
if it is 1, then im supposed to stop the program,
if n is odd, then n=n*3+1,
else n=n/2
What ive written is
int n;
cin>>n;
if (n==1)
{
cout<<n<<endl;
}
else if (n==??) ---> I'm supposed to write this as 'if n is an odd number, answer will be as follows..
{
n = 3*n + 1;
}
else
{
n = n/2;
}
cout<<n<<endl;
I;m not sure how do i do the ODD part.. Can anyone kindly help me in this.. Thank u..
Comment