Fibonacci sequence in AerScript implementation.
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
parent
010bdd7331
commit
aff19a98da
19
tests/fibonacci_sequence.aer
Normal file
19
tests/fibonacci_sequence.aer
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
class Program {
|
||||||
|
|
||||||
|
private int fib(int $n) {
|
||||||
|
int $last = 0;
|
||||||
|
int $cur = 1;
|
||||||
|
--$n;
|
||||||
|
while($n > 0) {
|
||||||
|
--$n;
|
||||||
|
int $tmp = $cur;
|
||||||
|
$cur = $last + $cur;
|
||||||
|
$last = $tmp;
|
||||||
|
}
|
||||||
|
return $cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int main() {
|
||||||
|
var_dump($this->fib(43));
|
||||||
|
}
|
||||||
|
}
|
1
tests/fibonacci_sequence.exp
Normal file
1
tests/fibonacci_sequence.exp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int(433494437)
|
Loading…
Reference in New Issue
Block a user