Browse Source

Fibonacci sequence in AerScript implementation.

release/v0.1
Rafal Kupiec 2 years ago
parent
commit
aff19a98da
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 20 additions and 0 deletions
  1. +19
    -0
      tests/fibonacci_sequence.aer
  2. +1
    -0
      tests/fibonacci_sequence.exp

+ 19
- 0
tests/fibonacci_sequence.aer View 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
- 0
tests/fibonacci_sequence.exp View File

@ -0,0 +1 @@
int(433494437)

Loading…
Cancel
Save