This is a creation in Article, where the information may have evolved or changed.
Fibonacci.c#include <stdio.h>int Main () {printf ("%d", Fibonacci (40));} int Fibonacci (int n) {if (n < 2) {return 1; } return Fibonacci (n-2) + Fibonacci (n-1);}
Compiling: cflags= "-march=corei7-avx-o2-pipe" && gcc fibonacci.c
Run: Time./a.out
Results: 165580141
real 0m0.977s
user 0m0.975s
sys 0m0.002s
Fibonacci.javapublic class Fibonacci { Public static void main (String[] args) { system.out.println (Fibonacci (+)); } public static int fibonacci (int n) { if (n < 2) { return 1; } return fibonacci (n &NBSP;-&NBSP;2) + fibonACCI (n - 1); }}
Compilation: Javac Fibonacci.java
Run: Time Java Fibonacci
Results: 165580141
Real 0m0.681s
User 0m0.671s
SYS 0m0.016s
Fibonacci.gopackage mainimport "FMT" func Fibonacci (n int) int {if (n < 2) {return 1} Return Fibonacci (N-2) + Fibonacci (n-1)}func main () {FMT. Println (Fibonacci (40))}
Compiling: Go build fibonacci.go
Run: Time./fibonacci
Results: 165580141
Real 0m1.175s
User 0m1.173s
SYS 0m0.004s
From the results: Performance java > C > Go a little weird huh.