Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Fibonacci Regex

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

  
perl -le '(1 x $_++) =~ /^(1(??{1x$-[1]}))*$/ && print while 1'
and...
  
perl -le 'print "Fibonacci" if (1x(-1+pop)) =~ /^(1(??{1x$-[1]}))*$/' +<NUMBER>
both require 5.6 or higher
   MeowChow                                   
               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.

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found