From c64c6839640117bd6938bf6c5de6bdddc0ed0f93 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 22 Jul 2015 19:29:54 +0200 Subject: [PATCH] Fix computation of fibonacci numbers. --- sources/Example_SIMD.7c.c | 2 +- sources/Example_SIMD.7f.f | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/Example_SIMD.7c.c b/sources/Example_SIMD.7c.c index e083186..1d76cf7 100644 --- a/sources/Example_SIMD.7c.c +++ b/sources/Example_SIMD.7c.c @@ -14,7 +14,7 @@ int a[N], b[N], c[N]; #pragma omp declare simd inbranch int fib( int n ) { - if (n <= 2) + if (n <= 1) return n; else { return fib(n-1) + fib(n-2); diff --git a/sources/Example_SIMD.7f.f b/sources/Example_SIMD.7f.f index 212735f..1015741 100644 --- a/sources/Example_SIMD.7f.f +++ b/sources/Example_SIMD.7f.f @@ -21,7 +21,7 @@ program fibonacci end do write(*,*) "Done a(", N-1, ") = ", a(N-1) - ! 44 1134903168 + ! 44 701408733 end program recursive function fib(n) result(r) @@ -29,7 +29,7 @@ recursive function fib(n) result(r) implicit none integer :: n, r - if (n <= 2) then + if (n <= 1) then r = n else r = fib(n-1) + fib(n-2)