Blame view
fibonacci.php
370 Bytes
cd7c3b792 e41d3f75-d864-476... |
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 |
#!/usr/bin/env php <?php if(! isset($argv[1]) || ! is_numeric($argv[1]) || intval($argv[1]) <= 0){ printf("Usage: %s nbr_int nbr_int: Un nombre entier supérieur à 0 ", $argv[0]); exit(1); } $nbr_int = intval($argv[1]); $a = 0; $b = 1; while ($b < $nbr_int) { printf("%d ", $b); $b = $a + $b; $a = $b - $a; } printf("b/a = %1.15f ", $b/$a); exit(0); |