Skip to content

Commit c65fe47

Browse files
committed
Merge pull request #15 from jakubjelinek/master
Fix computation of fibonacci numbers.
2 parents 3f83389 + c64c683 commit c65fe47

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sources/Example_SIMD.7c.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int a[N], b[N], c[N];
1414
#pragma omp declare simd inbranch
1515
int fib( int n )
1616
{
17-
if (n <= 2)
17+
if (n <= 1)
1818
return n;
1919
else {
2020
return fib(n-1) + fib(n-2);

sources/Example_SIMD.7f.f

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ program fibonacci
2121
end do
2222

2323
write(*,*) "Done a(", N-1, ") = ", a(N-1)
24-
! 44 1134903168
24+
! 44 701408733
2525
end program
2626

2727
recursive function fib(n) result(r)
2828
!$omp declare simd(fib) inbranch
2929
implicit none
3030
integer :: n, r
3131

32-
if (n <= 2) then
32+
if (n <= 1) then
3333
r = n
3434
else
3535
r = fib(n-1) + fib(n-2)

0 commit comments

Comments
 (0)