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

Re^3: Fibonacci Sequence

by tobyink (Abbot)
on Mar 05, 2013 at 14:48 UTC ( #1021836=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Fibonacci Sequence
in thread Fibonacci Sequence

$"++;_:while(++$"){$"%$_||next(_)for 2..$"-1;print$",$/}

Update: trizen has pointed out that this is more efficient:

$"++;_:while(++$"){$"%$_||next(_)for 2..sqrt$";print$",$/}

... but I don't like the two extra keystrokes required. Meanwhile, this solution gives you a minor efficiency boost without any extra nasty keystroke things...

$"++;_:while(++$"){$"%$_||next(_)for 2..$"/2;print$",$/}
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name


Comment on Re^3: Fibonacci Sequence
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-21 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls