Skip to content

Instantly share code, notes, and snippets.

@tpope
Created June 10, 2010 22:59
Show Gist options
  • Select an option

  • Save tpope/433761 to your computer and use it in GitHub Desktop.

Select an option

Save tpope/433761 to your computer and use it in GitHub Desktop.
def luhn?n;s=0;n.size.times{|i|x=n[-i-1,1].to_i*(i%2+1);s+=x>9?x+1:x};s%10==0;end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment