C problems validating a credit card

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

/s/\([5-9]\)\([0-9]\):\(.*\) /:1

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

456789012345678/ : adds/\([0-9]\)0:/

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

:/s/\([0-9]\)1:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)2:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)3:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)4:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)5:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)6:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)7:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)8:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/s/\([0-9]\)9:\(.*

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.This time I'm stuck with this assignment from CS50 Harvard course called "credit". PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/! PRINT IIF$(Luhn Check Passed("49927398717"), "passed", "failed") ' this test is expected to fail: CON. arg&true|false)) )& test$49927398716& test$49927398717& test$1234567812345678& test$1234567812345670& ; Note that the original implementation, which follows, is flawed because it assumes that n is a number which, when represented as a string, has an even number of characters.

||

Hello everyone , i'm new to programming, and get often stuck when making some programming exercises, but I usually managed to just google the problem.

This time I'm stuck with this assignment from CS50 Harvard course called "credit".

PRINT IIF$(Luhn Check Passed("1234567812345678"), "passed", "failed") ' this test is expected to pass: CON. (modulo s 10)) (let*-values ([(q r) (quotient/remainder n 10)] [(rq rr) (quotient/remainder (* (if odd? ) ( s rq rr)))))) (map luhn-test '(49927398716 49927398717 1234567812345678 1234567812345670));; - flunked the Luhn test, credit card number: 49927398716 passed the Luhn test, credit card number: 49927398717 passed the Luhn test, credit card number: 1234567812345678 flunked the Luhn test, credit card number: 1234567812345670 /* Rexx **************************************************** Walter Pachl* Implements the task's description in a rather concise way* Instead of reverting the ccn work it backwards**********************************************************/ " cardtest(test[n]) nlnext func cardtest(numstr) revstring = revstr(numstr) s1 = revodd(revstring) s2 = reveven(revstring) s3 =right(string(s1 s2), 1) if s3 = "0" return "Valid" else return "Invalid" ok func revstr(str) strnew = "" for nr = len(str) to 1 step -1 strnew = strnew str[nr] next return strnew func revodd(str) strnew = "" for nr = 1 to len(str) step 2 strnew = strnew str[nr] next sumodd = 0 for p = 1 to len(strnew) sumodd = sumodd number(strnew[p]) next return sumodd func reveven(str) strnew = "" for nr = 2 to len(str) step 2 strnew = strnew str[nr] next lsteven = [] for p = 1 to len(strnew) add(lsteven, string(2*number(strnew[p]))) next arreven = list(len(lsteven)) for q = 1 to len(lsteven) sum = 0 for w = 1 to len(lsteven[q]) sum = sum lsteven[q][w] next arreven[q] = sum next sumarr = 0 for x = 1 to len(arreven) sumarr = sumarr arreven[x] next return sumarr card$(1) = "49927398716"card$(2) = "49927398717"card$(3) = "1234567812345678"card$(4) = "1234567812345670" for i = 1 to 4print card$(i);" ";luhn$(card$(i))next i FUNCTION luhn$(card$) lc = len(card$) for i = lc to 1 step -1 digit = val(mid$(card$,i,1)) if ((lc -i) mod 2) = 0 then chk Sum = chk Sum digit else chk Sum = chk Sum int(digit * 2.2) next i if chk Sum mod 10 = 0 then luhn$ = "True" else luhn$ = "False"end function# Split number into double evens and oddss/.*/&: /: splits/\([0-4]\)\([0-9]\):\(.*\) /:\1\1\3 \2/s/\([5-9]\)\([0-9]\):\(.*\) /:1\1\1\3 \2/t split # Set up addition lookup tables/\([0-9]\)*:\(.*\) \(.*\)/\1\2\23456789012345678/ : adds/\([0-9]\)0:/\1:/s/\([0-9]\)1:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)2:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)3:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)4:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)5:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)6:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)7:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)8:\(.*\1.\\([0-9]\).*\)/\3:\2/s/\([0-9]\)9:\(.*\1.\\([0-9]\).*\)/\3:\2/t add /0:/a\Pass/0:/!

.\([0-9]\).*\)/:/t add /0:/a\Pass/0:/!

as $in | reduce range(0; length) as $i ([]; if ($i % 2) == 0 then . * 2 | sumdigits) | add) as $s2 | 0 == ($s1 $s2) % 10 ;function luhntest(x:: Integer) d = reverse(digits(x)) s = sum(d[1:2:end]) s = sum(sum.(digits.(2d[2:2:end]))) return s % 10 == 0end for card in [49927398716, 49927398717, 1234567812345678, 1234567812345670] println(luhntest(card) ? ] :wordend to double.digit :digit output item :digit @0 ; output ifelse :digit 4 then sum = sum - 9 odd = not odd end for return sum % 10 == 0end function test = function(s) if is Valid(s) then print s ": valid" else print s ": invalid"end function test "49927398716"test "49927398717"test "1234567812345678"test "1234567812345670"proc luhn(cc): bool = const m = [0,2,4,6,8,1,3,5,7,9] var sum = 0 var odd = true for i in countdown(cc.high, 0): let digit = ord(cc[i]) - ord('0') sum = (if odd: digit else: m[digit]) odd = not odd sum mod 10 == 0 for cc in ["49927398716", "49927398717", "1234567812345678", "1234567812345670"]: echo cc," ",luhn(cc)/*------------------------------------------------------------------------------ Purpose: Applies Luhn Algorithm to check a Number Notes: Returns True/False Validation based on check digit------------------------------------------------------------------------------*/ This example highlights Order's unusual treatment of numbers. PRINT IIF$(Luhn Check Passed("49927398716"), "passed", "failed") ' this test is expected to fail: CON. #define ORDER_PP_DEF_8luhn_wk ORDER_PP_FN( fn(8N, \ 8lets((8P, 8unzip(8N, 8nil, 8nil, 8true)) \ (8O, 8seq_fold(8plus, 0, 8tuple_at_0(8P))) \ (8E, 8seq_fold(8plus, 0, \ 8seq_map(8dig_map, 8tuple_at_1(8P)))), \ 8is_0(8remainder(8plus(8O, 8E), 10)))) )#define ORDER_PP_DEF_8unzip ORDER_PP_FN( fn(8S, 8L, 8R, 8O, \ 8if(8is_nil(8S), \ 8pair(8L, 8R), \ 8if(8O, \ 8unzip(8seq_tail(8S), 8seq_push_back(8seq_head(8S), 8L), \ 8R, 8false), \ 8unzip(8seq_tail(8S), 8L, \ 8seq_push_back(8seq_head(8S), 8R), 8true)))) )#COMPILE EXE#DIM ALL#COMPILER PBCC 6 FUNCTION Luhn Check Passed(BYVAL dgts AS STRING) AS INTEGERLOCAL i, s, s1 AS DWORD dgts = STRREVERSE$(dgts) FOR i = 1 TO LEN(dgts) STEP 2 s = VAL(MID$(dgts, i, 1)) NEXT i FOR i = 2 TO LEN(dgts) STEP 2 s1 = 2 * VAL(MID$(dgts, i, 1)) IF s1 = 10 THEN s -= 9 END IF s = s1 NEXT i FUNCTION = NOT ISTRUE (s MOD 10)END FUNCTION FUNCTION PBMAIN () AS LONG ' this test is expected to pass: CON. CHTMLstretch H, CHTMLchild Node:function(t,e)}),s.mfrac. Startup Hook("Common HTML Jax Ready",function()), Math Jax.

Search for c problems validating a credit card:

c problems validating a credit card-19c problems validating a credit card-78c problems validating a credit card-35c problems validating a credit card-56

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “c problems validating a credit card”

  1. The site relies on an automatically renewing credit card authority. Talking from experience, to contact members or reply to messages, you have to buy credits on average between £1 &.