#!/usr/bin/perl -w if (luhn()==0) { print "valid\n"; } else { print "not valid\n"; } sub luhn { 1 2 3 4 5 6 +7 8 9 10 11 12 0123456789012345678901234567890123456789012345678901234567890123456789 +01234567890123456789012345678901234567890123456789012 $n='4564123800603607';$o=$_=reverse$n;$o=~s/.(.)/$1*2/ge;s/(.)./$1/ge; +$o=~s/(.)/$x+=$1/ge;s/(.)/$y+=$1/ge;return($x+$y)%10; }
metadoktor
"The doktor is in."
In reply to 122 Char Sub - Re: Luhn Number Golf
by metadoktor
in thread Luhn Number Golf
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |