Skip to content

Commit 3452756

Browse files
authored
Create 55_codechef_Easy_Fibonacci.cpp
1 parent fda83b3 commit 3452756

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

55_codechef_Easy_Fibonacci.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// main.cpp
3+
// fibonacciii
4+
//
5+
// Created by Prince Kumar on 23/09/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// code of Easy Fibonacci
9+
10+
#include <iostream>
11+
#include <math.h>
12+
using namespace std;
13+
int main()
14+
{
15+
int T; cin>>T;
16+
while(T--)
17+
{
18+
long long int x; cin>>x;
19+
long long int z = log2((long double)x);
20+
if(z==0)
21+
cout<<"0"<<endl;
22+
else if(z==1)
23+
cout<<"1"<<endl;
24+
else
25+
{
26+
int a = z%4;
27+
if(a==2)
28+
cout<<"2"<<endl;
29+
else if(a==3)
30+
cout<<"3"<<endl;
31+
else if(a==0)
32+
cout<<"0"<<endl;
33+
else if(a==1)
34+
cout<<"9"<<endl;
35+
}
36+
}
37+
}
38+
39+
40+
41+

0 commit comments

Comments
 (0)