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

Re: Luhn Number Golf

by PrakashK (Pilgrim)
on Feb 26, 2002 at 17:45 UTC ( #147662=note: print w/replies, xml ) Need Help??


in reply to Luhn Number Golf

Here's a sub with 62 characters. Expects the number as an argument and returns 1 or 0.

sub luhn { #2345678901234567890123456789012345678901234567890123456789012 for(pop=~/(.)(.)/g){($a+=$1)+=$_ for map{split//}2*$2}!($a%10) }
/prakash

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://147662]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-02-23 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (340 votes). Check out past polls.