refactoring of the instruction table; removed unused instructions PUSHTYPTYP and ERROR; new modulo operator %; new examples fibonacci.noja and isprime.noja
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
|
||||
fun fibonacci(n: int) {
|
||||
|
||||
if n < 0:
|
||||
error("Only non-negative integers allowed");
|
||||
|
||||
if n == 0 or n == 1:
|
||||
return 1;
|
||||
|
||||
if n == 2:
|
||||
return 2;
|
||||
|
||||
return fibonacci(n-1)
|
||||
+ fibonacci(n-2);
|
||||
}
|
||||
|
||||
print(fibonacci(10), "\n");
|
||||
Reference in New Issue
Block a user