Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Fibonacci Sequence

by hdb (Prior)
on Mar 05, 2013 at 12:01 UTC ( #1021812=note: print w/ replies, xml ) Need Help??

in reply to Re: Fibonacci Sequence
in thread Fibonacci Sequence

Loopy short version:

for(++$\;$/<$$;$/=($\+=$/)-$/){print $"}

Now can someone find a similar short expression for please?

Comment on Re^2: Fibonacci Sequence
Download Code
Replies are listed 'Best First'.
Re^3: Fibonacci Sequence
by tobyink (Abbot) on Mar 05, 2013 at 14:48 UTC
    $"++;_: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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2016-02-09 21:15 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (326 votes), past polls