aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/60_while_fibonacci.sy
blob: c1bf6805f8bbc68b5b09ecc9242954523868542a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int n;
int fib(int p){
	int a;
	int b;
	int c;
	a = 0;
	b = 1;
	if ( p == 0 ){
		return 0;
	}
	if ( p == 1 ){
		return 1;
	}
	while ( p > 1 ){
		c = a + b;
		a = b;
		b = c;
		p = p - 1;
	}
	return c;
}
int main(){
	n = getint();
	int res;
	res = fib( n );
	return res;
}