RosettaCodeData/Task/Anonymous-recursion/Jq/anonymous-recursion-2.jq

9 lines
213 B
Text
Raw Permalink Normal View History

2016-12-05 23:44:36 +01:00
def fib(n):
def aux: if . == 0 then 0
elif . == 1 then 1
else (. - 1 | aux) + (. - 2 | aux)
end;
if n < 0 then error("negative arguments not allowed")
else n | aux
end ;