Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Fibonacci Regex

by MeowChow (Vicar)
on Jul 22, 2001 at 00:20 UTC ( #98691=obfuscated: print w/replies, xml ) Need Help??

perl -le '(1 x $_++) =~ /^(1(??{1x$-[1]}))*$/ && print while 1'
perl -le 'print "Fibonacci" if (1x(-1+pop)) =~ /^(1(??{1x$-[1]}))*$/' +<NUMBER>
both require 5.6 or higher
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Fibonacci Regex
by nop (Hermit) on Jul 27, 2001 at 01:49 UTC
    would someone explain this magic? curious. thanks. nop
Re: Fibonacci Regex
by hacker_j99 (Beadle) on Jul 25, 2001 at 05:21 UTC
    i dont know if its just me but the second code is not displaying correctly but both are correct in using 5.6 or higher, although I learned that through hard knocks.

      You have to supply a numeric command-line argument. If it's a fibonacci number, it will print "Fibonacci". Otherwise, it prints nothing.
                     s aamecha.s a..a\u$&owag.print

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://98691]
Approved by root
[Lady_Aleena]: I'll just have to search for the files using the subs and open them up.
[Discipulus]: nice Perl dreams, folks.. shower->Dumas->bed
[erix]: pere ou fils?
[Lady_Aleena]: Discipulus, good night.
[Discipulus]: pere, le vicomte de bragelonne.. wonderfull
[erix]: I'll keep that in mind (haven't read), buona notte :)
[Discipulus]: oh erix but is the fourth of cycle;read them in order

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2017-05-23 19:57 GMT
Find Nodes?
    Voting Booth?