Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created June 9, 2010 19:19
Show Gist options
  • Save bernerdschaefer/432029 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/432029 to your computer and use it in GitHub Desktop.
def luhn?(c)(0..c.size).inject(0){|s,i|_=c[i,1].to_i;s+(i%2!=0?_:(_*2).to_s.split('').inject(0){|y,z|y+z.to_i})}%10==0 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment