-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccbb599
commit 963b4fe
Showing
6 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
contract get_fib_n(n:int){ | ||
let last_fib_calculated: int = 1; | ||
|
||
entry get_fib(n: int){ | ||
let fib_n: int = 1; | ||
let fib_n_1: int = 0; | ||
|
||
while(last_fib_calculated < n){ | ||
let temp:int = fib_n; | ||
fib_n = fib_n + fib_n_1; | ||
fib_n_1 = fib_n; | ||
last_fib_calculated = last_fib_calculated + 1; | ||
} | ||
let result:int = fib_n; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NOT IMPLEMENTED YET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
contract get_fib_n(n:int){ | ||
let last_fib_calculated: int = 1 ; | ||
|
||
entry get_fib(n: int){ | ||
let result: int = fib(n); | ||
last_fib_calculated = result; | ||
} | ||
|
||
func fib(n: int) : int{ | ||
else { | ||
let a: nat = 0 - 1; | ||
let b: int = n - 2; | ||
return fib(a) + fib(b); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
\__ProgramNode: contract node.idx(n : int) [<stat>; ... <stat>;] | ||
\__AttrDeclarationNode: n : int | ||
\__VarDeclarationNode: let last_fib_calculated = <expr> : int | ||
\__ ConstantNumNode: 1 | ||
\__EntryDeclarationNode: Entry get_fib(n : int) | ||
\__AttrDeclarationNode: n : int | ||
\__VarDeclarationNode: let result = <expr> : int | ||
\__CallNode: fib(<expr>, ..., <expr>) | ||
\__ VariableNode: n | ||
\__VarCallNode: last_fib_calculated = <expr> | ||
\__ VariableNode: result | ||
\__FuncDeclarationNode: def fib(n : int) : int | ||
n : int | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters