Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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'
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

Comment on Fibonacci Regex
Select or Download Code
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
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? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-07-29 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls