Help the Angry Professor

Many years ago there was a University named “ABST”. Professors of many categories you find here suppose- Cordial , Angry, Selfish, Funny and so on. Among those one of the professor named “A.K.M. Samsul Bhuiya” was so much angry in nature. He felt angry when anyone didn’t hear his command or don’t understand his speech. One day the professor was preparing to go to his research room. Before taking preparation,he ordered the man named “wahid” who was for switching on-off the lights of the university, to keep ON the all lights of the research room. But wahid had forgetful mind. After 10 minutes when the professor went to the research room, he saw that no light was on and he got angry. He shouted and shouted “Wahid, Wahid”. Wahid came to the professor and said sorry for his inconvenience. Then again the professor ordered Wahid to keep on all light. Then Wahid kept on/off the light but in a peculiar fashion. Suppose, if there were 3 lights in the research room . Wahid on/off the switches by following fashion ON-OFF-ON / ON-OFF-OFF / OFF-ON-OFF / OFF-OFF-ON / OFF-OFF-OFF . By seeing the fashion of Wahid, the Angry professor got wondered and instead of getting angry try to find out the possible ways of switching on-off. But its a matter of sorrow that, Angry professor can’t find out the order till now after 20 years. Now your task to help the Angry Professor.

INPUT
The input N is greater than 0 and less than or equal to 100 denotes the number of switch.
OUTPUT
Your task to show the possible ways of switching on-off designed by Wahid.

Sample Input:
2
3
5

Sample output:
3
5
13

Share

One thought on “Help the Angry Professor

  1. //#include
    //#include
    #include
    #include
    #include
    void main()
    {
    clrscr();
    int t;
    scanf(“%d”,&t);
    while(t–)
    {
    int a,b,m,d,e,n;
    //printf(“Enter your number\n”);
    scanf(“%d”,&n);
    if(n==0||n==1)
    printf(“1”);
    else
    {
    a=pow(2,n);
    b=a-1;
    m=n-2;
    d=m*m;
    e=b-d*2;
    printf(“%d\n”,e);
    }
    }
    getch();
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Lean Blog by Crimson Themes.