digits<\/em> (e.g. if 7 is multiplied by 2 then the resulting 14 is split into 1+4). If the sum of the digits is a multiple of 10, the number passes.<\/p>\r\nFor example, to check 345678, you’d split it into 3,4,5,6,7,8. Then multiply 3, 5 and 7 by 2 to give 6, 4, 10, 6, 14, 8. Then split all the digits again to give 6, 4, 1, 0, 6, 1, 4, 8. That adds up to 30 so 345678 would be a valid credit card number (if there wasn’t a set length).<\/p>\r\n
Just for fun, here’s a quick function in R to run the Luhn Algorithm on a number (or tell you the remainder so you can adjust):<\/p>\r\n[R]\r\nluhnCheck <- function(number,returnLogical=TRUE){\r\n numbers <- gsub('[^0-9]','',as.character(number))\r\n numbers <- as.numeric(strsplit(numbers,'')[[1]])\r\n selector<-seq(length(numbers)-1,1,-2)\r\n numbers[selector]<-numbers[selector]*2\r\n numbers[numbers > 9] <- numbers[numbers > 9] – 9\r\n remainder <- sum(numbers) %% 10\r\n if(returnLogical) return(remainder==0)\r\n else return(remainder)\r\n}\r\n[\/R]\r\n
So the next time some stupid web form needs a SIN number I’m going with 999999998.<\/p>\r\n","protected":false},"excerpt":{"rendered":"A while back it was tax season in Canada and a friend of mine was trying to do his taxes online. But since he was foreign and didn’t have a Social Insurance Number (their equivalent of an SSN), the helpful webapp wouldn’t let him print the thing (of course it only informed him of that […]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,417],"tags":[448,185,439,437,440,317,441,442],"_links":{"self":[{"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/posts\/356"}],"collection":[{"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/comments?post=356"}],"version-history":[{"count":22,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/posts\/356\/revisions"}],"predecessor-version":[{"id":378,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/posts\/356\/revisions\/378"}],"wp:attachment":[{"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/media?parent=356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/categories?post=356"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/scott.sherrillmix.com\/blog\/wp-json\/wp\/v2\/tags?post=356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}