Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function number_fits_criterion($a){
- $p = abs(pow($a, 2) - $a - 1);
- if(abs(pow($a, 2) - $a - 1) < pow(10, -14)){
- echo "p^2 - p - 1: $p\n";
- return false;
- }else{
- return true;
- }
- }
- $x = 1;
- $y = 1;
- $a = 1;
- while(number_fits_criterion($a)){
- //find next fib
- $temp = $y;
- $y = $y + $x;
- $x = $temp;
- $a = $y/$x;
- }
- echo "p: $a\n";
- echo "Fibonacci Numbers: $x, $y \n";
Advertisement
Add Comment
Please, Sign In to add comment