Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Fibonacci Generator

by neosamuri (Friar)
on May 27, 2007 at 05:49 UTC ( [id://617714]=note: print w/replies, xml ) Need Help??


in reply to Fibonacci Generator

Spurred a thought

use strict; print join( " ", ratios(fibLikeGen(15,1,1,1))), "\n"; sub fibLikeGen { my( $len, $n, @seq ); $n = shift; @seq = @_; @seq = (1,1) unless @seq; $len = @seq; for( my $i = $len; $i < $n; $i++) { $seq[$i] += $seq[$i - $_] foreach 1..$len; } return @seq; } sub ratios { my( @out ); for( my $i = 1; $i < @_; $i++) { $out[$i] = $_[$i]/$_[$i - 1]; } return @out; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found