Advertisement
thornik

Bench 'fibo' for D

Dec 5th, 2017
1,687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.25 KB | None | 0 0
  1. // ldc2.exe -release -m64 -O fibo.d
  2.  
  3. import std.conv;
  4. import std.stdio;
  5.  
  6. uint fib(uint n)
  7. {
  8.     return n < 2 ? 1 : fib(n-2) + fib(n-1);
  9. }
  10.  
  11. void main(string[] args)
  12. {
  13.     int n = args.length < 2 ? 1 : to!int(args[1]);
  14.     writeln(fib(n));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement