Created
February 1, 2012 11:01
-
-
Save tommitchell/1716485 to your computer and use it in GitHub Desktop.
Code for "sam's card"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class CardFind{ | |
public static void main (String[] args){ | |
int cardtotal = 52, start = 0000, y, z, thou, hund, ten, one, d_thou, d_ten, total = 0; | |
while (start < 9999){ | |
thou = start /1000 ; | |
z = start % 1000; | |
hund = z /100; | |
z = z % 100; | |
ten = z / 10; | |
one = z % 10; | |
// formatting the thousands row | |
if(hund > 4){ | |
int a_thou = thou*2; | |
int a = a_thou / 10; | |
int b = a_thou % 10; | |
d_thou = a+b; | |
} else { | |
d_thou = thou*2; | |
} | |
// formatting the tens row | |
if(ten > 4){ | |
int a_ten = ten*2; | |
int a = a_ten / 10; | |
int b = a_ten % 10; | |
d_ten = a+b; | |
} else { | |
d_ten = ten*2; | |
} | |
int testnum = cardtotal+d_thou+hund+d_ten+one; | |
if(testnum%10 == 0){ | |
System.out.println(""+thou+""+hund+""+ten+""+one+""); | |
total++; | |
} | |
start++; | |
} | |
System.out.println("done - in total there were "+total+" total combinations than generated "luhn compliant" numbers"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment