File: fib.mini

package info (click to toggle)
gforth 0.7.0+ds2-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,808 kB
  • sloc: ansic: 8,506; sh: 3,660; lisp: 1,783; makefile: 993; yacc: 186; sed: 141; lex: 102; awk: 21
file content (14 lines) | stat: -rw-r--r-- 228 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
func fib(n)
  var r;
  if n<2 then
    r:=1;
  else
    r:=fib(n-1)+fib(n-2);
  end if;
  return r; 
  // the language syntax (return only at end) leads to inefficient code here
end func;

func main()
  return fib(34);
end func;