Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 browsing the Monastery: (13)
As of 2017-10-20 16:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (264 votes). Check out past polls.

    Notices?