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

Re: Golf Challenge: FizzBuzz

by Moron (Curate)
on Mar 02, 2007 at 17:36 UTC ( #602915=note: print w/ replies, xml ) Need Help??


in reply to Golf Challenge: FizzBuzz

Or the slightly simplistic version that uses a precomputed LCM of 15:

print map $_%15?($_%5?($_%3?"$_\n":"fizz\n"):"buzz\n"):"fizzbuzz\n",(1 +..100);
update: typo corrected - thx liverpole

-M

Free your mind


Comment on Re: Golf Challenge: FizzBuzz
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-11-27 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (178 votes), past polls