Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/luhn-test-of-credit-card-numbers.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / luhn-test-of-credit-card-numbers.wiki` 62 lines ยท 1184 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text tv " valid\n" 8 text ti " invalid\n" 9 text n1 "`49927398716`" 10 text n2 "`49927398717`" 11 text n3 "`1234567812345678`" 12 text n4 "`1234567812345670`" 13 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 14 fn emit a view uchar * to void 15 o = ulong 0 16 while lt o len a bound 4096 17 k = write 1 a o sub len a o 18 if le k 0 19 exit 1 20 end 21 o = add o ulong k 22 end 23 end 24 note from the right, odd places add their digit, even places add the digit sum of twice the digit 25 fn luhn a view uchar * to bool 26 s = ulong 0 27 n = len a 28 for i ulong n 29 d = ulong sub get a sub sub n 1 i 48 30 if eq rem i 2 1 31 d = mul d 2 32 if gt d 9 33 d = sub d 9 34 end 35 end 36 s = add s d 37 end 38 ret eq rem s 10 0 39 end 40 fn show a view uchar * to void 41 emit a 42 if luhn a 43 emit tv 44 else 45 emit ti 46 end 47 end 48 fn main to int 49 show n1 50 show n2 51 show n3 52 show n4 53 ret 0 54 end 55 56 {{out}} 57

58 `49927398716` valid

59 `49927398717` invalid

60 `1234567812345678` invalid

61 `1234567812345670` valid

62