Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -1,45 +1,45 @@
class FibonacciSequence
**Prints the nth fibonacci number**
on start
args := program arguments
if args empty
print .fibonacci(8)
else
try
print .fibonacci(integer.parse(args[0]))
catch FormatException
print to Console.error made !, "Input must be an integer"
exit program with error code
catch OverflowException
print to Console.error made !, "Number too large"
exit program with error code
define fibonacci(n as integer) as integer is shared
**Returns the nth fibonacci number**
test
assert fibonacci(0) = 0
assert fibonacci(1) = 1
assert fibonacci(2) = 1
assert fibonacci(3) = 2
assert fibonacci(4) = 3
assert fibonacci(5) = 5
assert fibonacci(6) = 8
assert fibonacci(7) = 13
assert fibonacci(8) = 21
**Prints the nth fibonacci number**
body
a, b := 0, 1
for n
a, b := b, a + b
return a
on start
args := program arguments
if args empty
print .fibonacci(8)
else
try
print .fibonacci(integer.parse(args[0]))
catch FormatException
print to Console.error made !, "Input must be an integer"
exit program with error code
catch OverflowException
print to Console.error made !, "Number too large"
exit program with error code
define fibonacci(n as integer) as integer is shared
**Returns the nth fibonacci number**
test
assert fibonacci(0) = 0
assert fibonacci(1) = 1
assert fibonacci(2) = 1
assert fibonacci(3) = 2
assert fibonacci(4) = 3
assert fibonacci(5) = 5
assert fibonacci(6) = 8
assert fibonacci(7) = 13
assert fibonacci(8) = 21
body
a, b := 0, 1
for n
a, b := b, a + b
return a