Abraham Problem (Circle of death) Code Express Wipro
Abraham Problem (Circle of death)
using System;
class HelloWorld {
public int abrahamcode(int input1)
{
int temp=0;
for(int i=0;i<((int)input1/2)+2;i++)
{
if(Math.Pow(2,i)>input1)
{
temp=(int)Math.Pow(2,i-1);
break;
}
}
if(temp==input1)
{
return input1-1;
}
return (2*(input1-temp)-1);
}
static void Main() {
HelloWorld s=new HelloWorld();
int input1=10;
Console.WriteLine(s.abrahamcode(input1));
}
}