Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Don't ask to ask, just ask
 
PerlMonks  

Re: Zeckendorf representation

by jwkrahn (Monsignor)
on Aug 25, 2012 at 02:58 UTC ( #989681=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub is_fibonnacci {
        my $plus = (5 * $_[0] * $_[0]) + 4;
        my $mins = (5 * $_[0] * $_[0]) - 4;
        return is_perfect_square($plus) | is_perfect_square($mins);
    }
    
  2. or download this
    sub is_fibonnacci {
        my $plus = (5 * $_[0] * $_[0]) + 4;
        my $mins = $plus - 8;
        return is_perfect_square($plus) || is_perfect_square($mins);
    }
    
  3. or download this
    sub is_perfect_square {
        my $sqrt = int(sqrt($_[0]));
        return $sqrt * $sqrt == $_[0];
    }
    
  4. or download this
    sub is_perfect_square { int( $_[0] ** .5 ) ** 2 == $_[0] }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989681]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-04-17 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (440 votes), past polls