IBAN: Difference between revisions

6,702 bytes added ,  5 months ago
m
m (→‎{{header|Wren}}: Minor tidy)
 
(5 intermediate revisions by 5 users not shown)
Line 24:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">F mod97(numberstring)
V segstart = 0
V step = 9
Line 62:
L(account) [‘GB82 WEST 1234 5698 7654 32’,
‘GB82 TEST 1234 5698 7654 32’]
print(‘#. validation is: #.’.format(account, valid_iban(account)))</langsyntaxhighlight>
 
{{out}}
Line 71:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">package Iban_Code is
function Is_Legal(Iban : String) return Boolean;
end Iban_Code;</langsyntaxhighlight><syntaxhighlight lang Ada="ada">with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Containers.Hashed_Maps;
with Ada.Strings.Hash;
Line 160:
Nations.insert("TR", 26); Nations.insert("AE", 23);
Nations.insert("GB", 22); Nations.insert("VG", 24);
end Iban_Code;</langsyntaxhighlight>Testing:
<langsyntaxhighlight Adalang="ada">with Ada.Text_Io; use Ada.Text_Io;
with Iban_Code;
 
Line 181:
Check("GB82 TEST 1234 5698 7654 32");
Check("GB82 WEST 1243 5698 7654 32");
end Check_Iban;</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 is valid.
GB82WEST12345698765432 is valid.
Line 190:
=={{header|AppleScript}}==
 
<langsyntaxhighlight lang="applescript">on countryCodes()
-- A list of 34 lists. The nth list (1-indexed) contains country codes for countries having n-character IBANS.
return {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"NO"}, {"BE"}, ¬
Line 251:
set output to output as text
set AppleScript's text item delimiters to astid
return output</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight lang="applescript">"GB82 WEST 1234 5698 7654 32: valid
gb82 west 1234 5698 7654 32: valid
GB82 TEST 1234 5698 7654 32: invalid
SA03 8000 0000 6080 1016 7519: valid
ZZ12 3456 7890 1234 5678 12: invalid
IL62 0108 0000 0009 9999 999: valid"</langsyntaxhighlight>
 
=={{header|Arturo}}==
 
<langsyntaxhighlight lang="rebol">ibanSize: #[
AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16
BH: 22, BA: 20, BR: 29, BG: 22, CR: 21, HR: 21, CY: 28
Line 293:
loop ["GB82 WEST 1234 5698 7654 32"
"GB82 TEST 1234 5698 7654 32"] 'ib
-> print [ib "=> valid?" valid? ib]</langsyntaxhighlight>
 
{{out}}
Line 302:
=={{header|AutoHotkey}}==
{{works with|AutoHotkey 1.1}}
<langsyntaxhighlight AutoHotkeylang="autohotkey">IBANs := ["GB82 WEST 1234 5698 7654 32"
, "gb82 WEST 1234 5698 7654 32"
, "GB82WEST12345698765432"
Line 344:
}
return rem
}</langsyntaxhighlight>{{Out}}
GB82 WEST 1234 5698 7654 32 is valid.
gb82 WEST 1234 5698 7654 32 is valid.
Line 357:
This requires a gawk with extensions and GNU MP+MPFR support - it's usually the case. Some country codes are missing, the output is itself parsable.
 
<langsyntaxhighlight lang="awk">
@load "ordchr"
 
Line 407:
ibancsum % 97 == 1 ? valid() : invalid()
}</langsyntaxhighlight>
Creating a test file and launching the script:
<syntaxhighlight lang="text">
cat > test.iban
FR33 ^__^ 0BAD
Line 419:
^D
gawk -Mf iban.gawk test.iban
</syntaxhighlight>
</lang>
 
Output:
 
<syntaxhighlight lang="text">
INVALID FR33 ^__^ 0BAD
INVALID AA11 1234 6543 1212
Line 430:
VALID__ GB82 WEST 1234 5698 7654 32
INVALID GB82 TEST 1234 5698 7654 32
</syntaxhighlight>
</lang>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> REM Used the following as official standard:
REM http://www.cnb.cz/cs/platebni_styk/iban/download/EBS204.pdf
 
Line 526:
num$=MID$(num$,8)
ENDWHILE
=VALmod$</langsyntaxhighlight>{{out}}
valid IBAN: GB82 WEST 1234 5698 7654 32
valid IBAN: GB82WEST12345698765432
Line 542:
=={{header|Befunge}}==
 
<langsyntaxhighlight lang="befunge">>>" :NABI">:#,_>:~:"`"`48**-:55+-#v_$0::6g0>>8g-!\7g18g-!*!v>v>>
<<_#v:#78#`8#+<^+!!*-*84\-9:g8:p8\<oo>1#$-#<0$>>>#v_"dilav" ^#<<
>>^ >*-:20p9`9*1+55+**20g+"a"%10g1+00g%:4-!|^g6::_v#-*88:+1_vv>>
Line 549:
"-(&(/$$*$(*.-*.('$)*%0-&**.$'(.'/.+,''&&*.)**&,-.&.(*(*-!(%01-)
BFBBBBFFTNRRGGCCGCGGSSKSKSSDDHDHCPLPTLLLLPPAAVEIIAAAIEMMMNGMMMMI
ERGAHRIONLSOTRZYBRLIKIWMZAEOKREUHSBTRIVTUKLEDGESTLTZESEDCOEKUTRL</langsyntaxhighlight>
 
{{out}}
Line 560:
 
=={{header|Bracmat}}==
<langsyntaxhighlight lang="bracmat">( ( IBAN-check
= table country cd len N c
. (AL.28) (AD.24) (AT.20) (AZ.28) (BE.16) (BH.22) (BA.20) (BR.29)
Line 610:
& IBAN-check$"GB82 WEST 1243 5698 7654 32"
& IBAN-check$"GB82 west 1243 5698 7654 32"
);</langsyntaxhighlight>{{out}}
wrong length
invalid country code: 'GX'
Line 621:
 
=={{header|C}}==
<langsyntaxhighlight Clang="c">#include <alloca.h>
#include <ctype.h>
#include <stdio.h>
Line 717:
 
return 0;
}</langsyntaxhighlight>{{out}}
iban 'GB82 WEST 1234 5698 7654 32' GB82TEST12345698765432
GB82WEST12345698765432 is valid.
Line 723:
 
=={{header|C sharp}}==
<langsyntaxhighlight lang="csharp"> public class IbanValidator : IValidateTypes
{
public ValidationResult Validate(string value)
Line 841:
{"VG", 24}
};
}</langsyntaxhighlight>Demonstrating:
<langsyntaxhighlight lang="csharp"> public class When_the_IbanValidator_is_told_to_Validate
{
[Fact]
Line 941:
Assert.Equal(ValidationResult.IsValid, result);
}
}</langsyntaxhighlight>
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">#include <string>
#include <iostream>
#include <boost/algorithm/string.hpp>
Line 1,018:
SayValidity("GB82TEST12345698765432");
return 0;
}</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 is valid!
GB82TEST12345698765432 is not valid!
Line 1,024:
=={{header|Caché ObjectScript}}==
 
<langsyntaxhighlight lang="cos">Class Utils.Validate [ Abstract ]
{
 
Line 1,121:
}
 
}</langsyntaxhighlight>{{out|Examples}}
<pre>USER>For { Read iban Quit:iban="" Write " => ", ##class(Utils.Validate).VerifyIBAN(iban), ! }
GB82 WEST 1234 5698 7654 32 => 1
Line 1,134:
 
=={{header|Clojure}}==
<langsyntaxhighlight Clojurelang="clojure">(def explen
{"AL" 28 "AD" 24 "AT" 20 "AZ" 28 "BE" 16 "BH" 22 "BA" 20 "BR" 29
"BG" 22 "CR" 21 "HR" 21 "CY" 28 "CZ" 24 "DK" 18 "DO" 28 "EE" 20
Line 1,157:
 
(prn (valid-iban? "GB82 WEST 1234 5698 7654 32") ; true
(valid-iban? "GB82 TEST 1234 5698 7654 32")) ; false</langsyntaxhighlight>
 
=={{header|COBOL}}==
{{works with|OpenCOBOL}}
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. iban-main.
 
Line 1,321:
END PROGRAM create-iban-number.
 
END PROGRAM validate-iban.</langsyntaxhighlight>{{out}}
<pre>
GB82 WEST 1234 5698 7654 32 is valid.
Line 1,328:
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">
;;
;; List of the IBAN code lengths per country.
Line 1,390:
(= 1 (mod (IBAN-to-integer X) 97)))))
(validp (remove #\Space iban))))
</syntaxhighlight>
</lang>
'''Output:'''
<pre>
Line 1,403:
=={{header|D}}==
{{trans|Python}}
<langsyntaxhighlight lang="d">import std.stdio, std.string, std.regex, std.conv, std.bigint,
std.algorithm, std.ascii;
 
Line 1,439:
"GB82 TEST 1234 5698 7654 32"])
writefln("%s validation is: %s", account, account.validIBAN);
}</langsyntaxhighlight>{{out}}
<pre>GB82 WEST 1234 5698 7654 32 validation is: true
GB82 TEST 1234 5698 7654 32 validation is: false</pre>
 
=={{header|DBL}}==
<syntaxhighlight lang="dbl">;
<lang DBL>;
; Validate IBAN for DBL version 4 by Dario B.
;
Line 1,599:
ELSE ISVALID=
XRETURN
END</langsyntaxhighlight>
{{out}}
<pre>GB82 WEST 1234 5698 7654 32 is valid
Line 1,613:
=={{header|Elixir}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="elixir">defmodule IBAN do
@len %{ AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16, BH: 22, BA: 20, BR: 29,
BG: 22, CR: 21, HR: 21, CY: 28, CZ: 24, DK: 18, DO: 28, EE: 20,
Line 1,648:
"GB82 TEST 1234 5698 7654 32",
"ZZ12 3456 7890 1234 5678 12" ]
|> Enum.each(fn iban -> IO.puts "#{IBAN.valid?(iban)}\t#{iban}" end)</langsyntaxhighlight>
 
{{out}}
Line 1,661:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">open System
open System.Text.RegularExpressions
 
Line 1,712:
|> function | Some(_) -> "a valid IBAN" | None -> "an invalid IBAN"
|> printfn "%s is %s" iban
0</langsyntaxhighlight>{{out}}
>Rosetta.exe "GB82 WEST 1234 5698 7654 32"
GB82 WEST 1234 5698 7654 32 is a valid IBAN
Line 1,720:
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: assocs combinators.short-circuit formatting kernel math
math.parser regexp sequences sets qw unicode ;
IN: rosetta-code.iban
Line 1,769:
] bi@ ;
 
MAIN: iban-demo</langsyntaxhighlight>
{{out}}
<pre>
Line 1,778:
=={{header|Forth}}==
{{Works with|4tH|3.62.3}}
<syntaxhighlight lang="text">include lib/ulcase.4th \ for S>UPPER
include lib/triple.4th \ for UT/MOD
include lib/cstring.4th \ for C/STRING
Line 1,815:
;
 
checkiban</langsyntaxhighlight>
{{Out}}
<pre>linux:~> pp4th -x chkiban.4th
Line 1,825:
 
=={{header|Fortran}}==
<langsyntaxhighlight lang="fortran">
program ibancheck
 
Line 1,950:
 
end program ibancheck
</syntaxhighlight>
</lang>
 
{{out}}
Line 1,969:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
' List updated to release 72, 25 November 2016, of IBAN Registry (75 countries)
Line 2,040:
Print
Print "Press any key to quit"
Sleep</langsyntaxhighlight>
 
{{out}}
Line 2,050:
=={{header|Free Pascal}}==
{{libheader|GMP}}
<langsyntaxhighlight Delphilang="delphi">{$mode objFPC}
 
uses
Line 2,130:
// note, strings longer than 34 characters will be silently clipped
writeLn(isLegal(delSpace('GB82 WEST 1234 5698 7654 32')));
end.</langsyntaxhighlight>
{{out}}
<pre>TRUE</pre>
Line 2,136:
=={{header|Go}}==
 
<langsyntaxhighlight Golang="go">package main
 
import (
Line 2,205:
}
}
</syntaxhighlight>
</lang>
 
=={{header|Groovy}}==
<langsyntaxhighlight lang="groovy">def validateIBAN(String iban) {
def iso = [AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16, BH: 22, BA: 20, BR: 29, BG: 22,
HR: 21, CY: 28, CZ: 24, DK: 18, DO: 28, EE: 20, FO: 18, FI: 18, FR: 27, GE: 22, DE: 22, GI: 23,
Line 2,223:
def number = iban.collect { Character.digit(it as char, 36) }.join('')
(number as BigInteger).mod(97) == 1
}</langsyntaxhighlight>
 
Testing:
<langsyntaxhighlight lang="groovy">[ 'GB82 WEST 1234 5698 7654 32',
'GB82 TEST 1234 5698 7654 32',
'GB81 WEST 1234 5698 7654 32',
Line 2,232:
'CH93 0076 2011 6238 5295 7' ].each { iban ->
println "$iban is ${validateIBAN(iban) ? 'valid' : 'invalid'}"
}</langsyntaxhighlight>
{{output}}
<pre>GB82 WEST 1234 5698 7654 32 is valid
Line 2,242:
=={{header|Haskell}}==
This program uses the Maybe and Either monads to handle failures. Values of type 'Maybe a' can contain 'Nothing' (no value) or 'Just a' (a value of type 'a'). Values of type 'Either a b' contain 'Left b' (usually indicating failure) or 'Right c' (usually indicating success).
<langsyntaxhighlight Haskelllang="haskell">import Data.Char (toUpper)
import Data.Maybe (fromJust)
 
Line 2,294:
 
invalidBecause reason = Left $ "Invalid IBAN number " ++ xs ++
": " ++ reason</langsyntaxhighlight>{{out}}
<pre>
validateIBAN "GB82 WEST 1234 5698 7654 32"
Line 2,316:
 
=={{header|IS-BASIC}}==
<langsyntaxhighlight ISlang="is-BASICbasic">100 PROGRAM "IBAN.bas"
110 STRING CO$(1 TO 93)*2
120 NUMERIC LG(1 TO 93)
Line 2,373:
650 DATA AD,24,AE,23,AL,28,AO,25,AT,20,AZ,28,BA,20,BE,16,BF,28,BG,22,BH,22,BI,16,BJ,28,BR,29,BY,28,CG,27,CH,21,CI,28,CM,27,CR,22,CV,25,CY,28,CZ,24,DE,22,DK,18,DO,28,DZ,24,EE,20,EG,27,ES,24,FI,18,FO,18,FR,27,GA,27,GB,22,GE,22,GI,23,GL,18
660 DATA GR,27,GT,28,HN,28,HR,21,HU,28,IE,22,IL,23,IR,26,IS,26,IT,27,JO,30,KM,27,KW,30,KZ,20,LB,28,LI,21,LT,20,LU,20,LV,21,MA,28,MC,27,MD,24,ME,22,MG,27,MK,19,ML,28,MR,27,MT,31,MU,30,MZ,25,NE,28,NI,32,NL,18,NO,15,PK,24,PL,28,PS,29,PT,25
670 DATA QA,29,RO,24,RS,22,SA,24,SE,24,SI,19,SK,24,SM,27,SN,28,TD,27,TG,28,TL,23,TN,24,TR,26,UA,29,VG,24,XK,20</langsyntaxhighlight>
 
=={{header|J}}==
<langsyntaxhighlight Jlang="j">NB. delete any blank characters
delblk =. #~ ' '&~:
NB. rearrange
Line 2,410:
NB. IBAN
iban =: quads @: ibancheck
</langsyntaxhighlight>{{out}}
<pre>
iban 'GB82 WEST 1234 5698 7654 32'
Line 2,425:
=={{header|Java}}==
{{works with|Java|8+}}
<langsyntaxhighlight lang="java">import java.math.BigInteger;
import java.util.*;
 
Line 2,475:
return bigInt.mod(BigInteger.valueOf(97)).intValue() == 1;
}
}</langsyntaxhighlight>{{out}}
<pre>GB82 WEST 1234 5698 7654 32 is valid.
GB82 TEST 1234 5698 7654 32 is not valid.
Line 2,487:
 
=={{header|JavaScript}}==
<langsyntaxhighlight JavaScriptlang="javascript">var ibanLen = {
NO:15, BE:16, DK:18, FI:18, FO:18, GL:18, NL:18, MK:19,
SI:19, AT:20, BA:20, EE:20, KZ:20, LT:20, LU:20, CR:21,
Line 2,514:
document.write(isValid('GB82 TEST 1234 5698 7654 32'), '<br>') // false
document.write(isValid('SA03 8000 0000 6080 1016 7519'), '<br>') // true
</syntaxhighlight>
</lang>
{{out}}
true
Line 2,525:
This implementation requires a version of jq with <tt>gsub</tt>.
 
The heart of the matter consists of just four lines of straightforward jq code:<langsyntaxhighlight lang="jq">
# strip the input string of spaces and tabs:
gsub("[ \t]";"")
Line 2,534:
# check the mod 97 criterion:
and ( (.[4:] + .[0:4]) | letters2digits | remainder) == 1
</syntaxhighlight>
</lang>
This conciseness is achieved courtesy of the helper functions: <tt>letters2digits</tt> and <tt>remainder</tt>. These could be implemented as inner functions of the main function,
but for clarity they are shown as top-level functions here.
<langsyntaxhighlight lang="jq">def letters2digits:
65 as $A | 90 as $Z
| ($A - 10) as $ten
Line 2,552:
# output: its remainder modulo 97 as a number
def remainder:
if length < 15 then (.|tonumber) % 97
else (.[0:14] | remainder | tostring) as $r1
| ($r1 + .[14:]) | remainder
Line 2,574:
and length == $lengths[.[0:2]]
# Shift and convert:
and ( (.[4:] + .[0:4]) | letters2digits | remainder) == 1 ;</langsyntaxhighlight>Examples<syntaxhighlight lang ="jq">
"GB82 WEST 1234 5698 7654 32" | is_valid_iban #=> true
"GB82 TEST 1234 5698 7654 32" | is_valid_iban #=> false</langsyntaxhighlight>
 
=={{header|Jsish}}==
From the Javascript entry.
<langsyntaxhighlight lang="javascript">var ibanLen = {
NO:15, BE:16, DK:18, FI:18, FO:18, GL:18, NL:18, MK:19,
SI:19, AT:20, BA:20, EE:20, KZ:20, LT:20, LU:20, CR:21,
Line 2,617:
isIBAN('SA03 8000 0000 6080 1016 7519') ==> true
=!EXPECTEND!=
*/</langsyntaxhighlight>
 
{{out}}
Line 2,626:
{{works with|Julia|0.6}}
 
<langsyntaxhighlight lang="julia">function validiban(iban::AbstractString)
country2length = Dict(
"AL" => 28, "AD" => 24, "AT" => 20, "AZ" => 28, "BE" => 16, "BH" => 22, "BA" => 20, "BR" => 29,
Line 2,647:
digs = parse(BigInt, join(parse(Int, ch, 36) for ch in iban))
return rst && digs % 97 == 1
end</langsyntaxhighlight>
 
{{out}}
Line 2,654:
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">// version 1.0.6
 
import java.math.BigInteger
Line 2,697:
println(iban + if (valid) " may be valid" else " is not valid")
}
}</langsyntaxhighlight>
 
{{out}}
Line 2,703:
GB82 WEST 1234 5698 7654 32 may be valid
GB82 TEST 1234 5698 7654 32 is not valid
</pre>
 
=== With IBAN REGISTRY parser ===
<syntaxhighlight lang="kotlin">
 
package rosettacode
 
import rosettacode.Outcome.Fail
import rosettacode.Outcome.Ok
import java.lang.IllegalArgumentException
import java.math.BigInteger
 
sealed class Outcome {
 
object Ok : Outcome() {
override fun toString(): String = "Ok"
}
 
data class Fail(val error: String) : Outcome()
}
 
fun Boolean.asOutcome(error: String = "") = when (this) {
true -> Ok
false -> Fail(error)
}
 
/**
* A validator based on a pattern (e.g GB2!n4!a6!n8!n) as defined in the IBAN REGISTRY
* Doesn't handle variable length IBANs - sufficient for Rosetta
*
* IBAN REGISTRY: https://www.swift.com/swift_resource/9606
*/
class Validator(private val pattern: String) {
private val triplet: Regex = """(\d+)!([n,a,c])""".toRegex() // e.g: 10!n
private val rules: List<Regex>
 
init {
val countTypePairs = triplet
.findAll(pattern)
.map { Pair(it.groups[1]!!.value.toInt(), it.groups[2]!!.value) }
 
rules = countTypePairs.fold(emptyList()) { acc, p ->
acc + when (p.second) {
"n" -> """[0-9]{${p.first}}""".toRegex()
"a" -> """[A-Z]{${p.first}}""".toRegex()
"c" -> """[A-Z,0-9]{${p.first}}""".toRegex()
else -> throw IllegalArgumentException("Unexpected pattern: $pattern")
}
}
}
 
fun isValid(ccbban: String): Outcome {
var k = 0
 
for (rule in rules) {
when (val match = rule.matchAt(ccbban, k)) {
null -> return Fail("failed rule: $rule")
else -> {
k = match.range.last + 1
}
}
}
return (k == ccbban.length).asOutcome("IBAN is too long")
}
}
 
object Registry : MutableMap<String, Validator> by mutableMapOf()
 
fun String.split(i: Int) = Pair(this.substring(0, i), this.substring(i))
fun String.toDigits() = this.fold("") { acc, ch -> acc + Character.getNumericValue(ch) }
fun Pair<String, String>.swap() = this.second + this.first
 
object CDCheck {
private val _97 = BigInteger.valueOf(97)
private val _1 = BigInteger.ONE
 
operator fun invoke(digits: String) = (BigInteger(digits).mod(_97) == _1).asOutcome("Invalid Check Digits")
}
 
fun validate(iban: String): Outcome {
val normalized = iban.replace(" ", "").uppercase().also {
if (it.length < 5) {
return Fail("IBAN is too short")
}
}
 
val (cc, tail) = normalized.split(2)
val validator = Registry[cc] ?: return Fail("Unknown Country Code: $cc")
 
return when (val outcome = validator.isValid(tail)) {
is Fail -> outcome
is Ok -> {
val allDigits = normalized
.split(4).swap() // (CC + CD) -> end
.toDigits() // letters -> digits
CDCheck(allDigits)
}
}
}
 
fun main() {
Registry["GB"] = Validator("GB2!n4!a6!n8!n")
Registry["DE"] = Validator("DE2!n8!n10!n")
 
validate("GB82WEST12345698765432").also { println(it) } // Ok
validate("GB82 WEST 1234 5698 7654 32").also { println(it) } // Ok
 
validate("DE89370400440532013000").also { println(it) } // Ok
 
validate("XX82WEST1234569A765432").also { println(it) } // Unknown Country Code: XX
validate("GB82").also { println(it) } // IBAN is too short
validate("GB82WEST1234569A765432").also { println(it) } // failed rule: [0-9]{8}
validate("GB82WE5T1234569A765432").also { println(it) } // failed rule: [A-Z]{4}
validate("GB82WEST123456987654329").also { println(it) } // IBAN is too long
validate("GB80WEST12345698765432").also { println(it) } // Invalid Check Digits
}
</syntaxhighlight>
 
{{out}}
<pre>
Ok
Ok
Ok
Fail(error=Unknown Country Code: XX)
Fail(error=IBAN is too short)
Fail(error=failed rule: [0-9]{8})
Fail(error=failed rule: [A-Z]{4})
Fail(error=IBAN is too long)
Fail(error=Invalid Check Digits)
</pre>
 
=={{header|Lobster}}==
<syntaxhighlight lang="lobster">
<lang Lobster>
let cc = ["AD","AE","AL","AO","AT","AZ","BA","BE","BF","BG","BH","BI","BJ","BR","CG","CH","CI","CM","CR","CV","CY",
"CZ","DE","DK","DO","DZ","EE","EG","ES","FI","FO","FR","GA","GB","GE","GI","GL","GR","GT","HR","HU","IE",
Line 2,766 ⟶ 2,895:
assert not isValidIBAN("GB82 TEST 1234 5698 7654 32")
assert not isValidIBAN("GB82 WEST 1243 5698 7654 32")
</syntaxhighlight>
</lang>
 
=={{header|Logtalk}}==
<langsyntaxhighlight lang="logtalk">
:- object(iban).
 
Line 2,899 ⟶ 3,028:
 
:- end_object.
</syntaxhighlight>
</lang>
Testing:
<langsyntaxhighlight lang="logtalk">
| ?- iban::valid("GB82 WEST 1234 5698 7654 32").
yes
</syntaxhighlight>
</lang>
 
=={{header|Lua}}==
<langsyntaxhighlight lang="lua">local length=
{
AL=28, AD=24, AT=20, AZ=28, BH=22, BE=16, BA=20, BR=29, BG=22, CR=21,
Line 2,930 ⟶ 3,059:
end
return mod==1
end</langsyntaxhighlight>
 
=={{header|M2000 Interpreter}}==
We make a lambda function which return a string, with the input IBAN plus (Valid) or (Invalid) at the end.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
\\ IBAN checker
Function MakeIBANfun$ {
Line 2,977 ⟶ 3,106:
Print IbanCheck$("GR16 0110 1250 0000 0001 2300 695X")
Print IbanCheck$("MK11 2222 3333 4444 555")
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">CountryCodes={{"AL",28},{"AD",24},{"AT",20},{"AZ",28},{"BE",16},{"BH",22},{"BA",20},{"BR",29},{"BG",22},{"CR",21},{"HR",21},{"CY",28},{"CZ",24},{"DK",18},{"DO",28},{"EE",20},{"FO",18},{"FI",18},{"FR",27},{"GE",22},{"DE",22},{"GI",23},{"GR",27},{"GL",18},{"GT",28},{"HU",28},{"IS",26},{"IE",22},{"IL",23},{"IT",27},{"KZ",20},{"KW",30},{"LV",21},{"LB",28},{"LI",21},{"LT",20},{"LU",20},{"MK",19},{"MT",31},{"MR",27},{"MU",30},{"MC",27},{"MD",24},{"ME",22},{"NL",18},{"NO",15},{"PK",24},{"PS",29},{"PL",28},{"PT",25},{"RO",24},{"SM",27},{"SA",24},{"RS",22},{"SK",24},{"SI",19},{"ES",24},{"SE",24},{"CH",21},{"TN",24},{"TR",26},{"AE",23},{"GB",22},{"VG",24}};
ClearAll[IBANVerify]
IBANVerify[input_String]:=Module[{i,cc,rules},
Line 3,008 ⟶ 3,137:
False
]
]</langsyntaxhighlight>
Trying out the function:
<langsyntaxhighlight Mathematicalang="mathematica">IBANVerify["GB82 WEST 1234 5698 7654 32"]
IBANVerify["GB82 WEST 1234 5698 7654 323"]
IBANVerify["GB82 WEST 1234 5698 7654 31"]
IBANVerify["XX82 WEST 1234 5698 7654 323"]</langsyntaxhighlight>{{out}}
True
False
Line 3,021 ⟶ 3,150:
=={{header|MATLAB}}==
Didn't check country codes, lengths, or consistent checksums to keep this applicable to any new countries.
<langsyntaxhighlight MATLABlang="matlab">function valid = validateIBAN(iban)
% Determine if International Bank Account Number is valid IAW ISO 13616
% iban - string containing account number
Line 3,050 ⟶ 3,179:
i2 = min(i1+8, nDig);
end
end</langsyntaxhighlight>Usage:
<langsyntaxhighlight MATLABlang="matlab">tests = {'GB82 WEST 1234 5698 7654 32' ;
'GB82 TEST 1234 5698 7654 32' ;
'CH93 0076 2011 6238 5295 7' ;
Line 3,061 ⟶ 3,190:
for k = 1:length(tests)
fprintf('%s -> %svalid\n', tests{k}, char(~validateIBAN(tests{k}).*'in'))
end</langsyntaxhighlight>{{out}}
<pre>GB82 WEST 1234 5698 7654 32 -> valid
GB82 TEST 1234 5698 7654 32 -> invalid
Line 3,072 ⟶ 3,201:
 
=={{header|NewLISP}}==
<syntaxhighlight lang="newlisp">
<lang NewLISP>
(setq *iban-code-length* '((15 ("NO"))
(16 ("BE"))
Line 3,140 ⟶ 3,269:
)
)
</syntaxhighlight>
</lang>
Output:
<pre>
Line 3,152 ⟶ 3,281:
=={{header|Nim}}==
{{libheader|bigints}}
<langsyntaxhighlight lang="nim">import tables, strutils, re, bigints
 
let countryLen = toTable({
Line 3,185 ⟶ 3,314:
 
for account in ["GB82 WEST 1234 5698 7654 32", "GB82 TEST 1234 5698 7654 32"]:
echo account, " validation is: ", validIban account</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 validation is: true
GB82 TEST 1234 5698 7654 32 validation is: false
Line 3,191 ⟶ 3,320:
=={{header|Oberon-2}}==
Works with oo2c Version 2
<langsyntaxhighlight lang="oberon2">
MODULE IBAN;
IMPORT
Line 3,353 ⟶ 3,482:
Test;
END IBAN.
</syntaxhighlight>
</lang>
Output:
<pre>
Line 3,364 ⟶ 3,493:
=={{header|OCaml}}==
{{works with|OCaml|4.03+}}
<langsyntaxhighlight lang="ocaml">
#load "str.cma"
#load "nums.cma" (* for module Big_int *)
Line 3,471 ⟶ 3,600:
in
List.iter (fun pair -> testit pair) ibans
</syntaxhighlight>
</lang>
{{out}}
GB82 WEST 1234 5698 7654 32 is valid. Expected true [PASS]
Line 3,482 ⟶ 3,611:
 
=={{header|Perl}}==
<langsyntaxhighlight Perllang="perl">#!/usr/bin/perl
use strict ;
use warnings ;
Line 3,529 ⟶ 3,658:
if ( validate_iban( "GB82TEST12345698765432" ) ) {
print "GB82TEST12345698765432 is valid!\n" ;
}</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 is a valid IBAN number!
GB82TEST12345698765432 is invalid!
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\IBAN.exw
Line 3,594 ⟶ 3,723:
<span style="color: #000000;">test</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"SA03 8000 0000 6080 1016 7519"</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">test</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"CH93 0076 2011 6238 5295 7"</span><span style="color: #0000FF;">,</span><span style="color: #004600;">true</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 3,605 ⟶ 3,734:
 
=={{header|PHP}}==
<langsyntaxhighlight lang="php">
<?php
 
Line 3,685 ⟶ 3,814:
echo "IBAN NOT VALID";
}
</syntaxhighlight>
</lang>
 
=={{header|Picat}}==
<langsyntaxhighlight Picatlang="picat">go =>
IBAN = "GB82 WEST 1234 5698 7654 32",
println(IBAN=iban(IBAN)),
Line 3,721 ⟶ 3,850:
"MR"=27, "MU"=30, "MC"=27, "MD"=24, "ME"=22, "NL"=18, "NO"=15, "PK"=24, "PS"=29, "PL"=28,
"PT"=25, "QA"=29, "RO"=24, "SM"=27, "SA"=24, "RS"=22, "SK"=24, "SI"=19, "ES"=24, "SE"=24,
"CH"=21, "TN"=24, "TR"=26, "AE"=23, "GB"=22, "VG"=24]).</langsyntaxhighlight>
 
{{out}}
Output:
<pre>GB82 WEST 1234 5698 7654 32 = ok</pre>
 
===Some more (and interesting) tests:===
<langsyntaxhighlight Picatlang="picat">go2 =>
Ibans = ["GB82 WEST 1234 5698 7654 32",
"gb82 WEST 1234 5698 7654 32",
Line 3,745 ⟶ 3,874:
println(IBAN=iban(IBAN))
end,
nl.</langsyntaxhighlight>
 
{{out}}
Output:
<pre>GB82 WEST 1234 5698 7654 32 = ok
gb82 WEST 1234 5698 7654 32 = ok
Line 3,760 ⟶ 3,889:
CH93 0076 2011 6238 5295 7 = ok
IL62 0108 0000 0009 9999 999 = ok</pre>
 
 
=={{header|PicoLisp}}==
<langsyntaxhighlight Picolisplang="picolisp">(setq *Sizes '((GB . 22) (CH . 21) (SA . 24)))
 
(de iban (Str)
Line 3,792 ⟶ 3,920:
(println 'Invalid) ) )
 
(bye)</langsyntaxhighlight>
 
=={{header|PowerShell}}==
<syntaxhighlight lang="powershell">
<lang PowerShell>
function verifIBAN ([string]$ibanS)
{
Line 3,822 ⟶ 3,950:
}
} #fin fonction vérification IBAN / Stéphane RABANY 2018
</syntaxhighlight>
</lang>
 
Ancien texte qui ne sert à rien selon moi :
I have heard that Regex should not be used with IBAN codes. Regex does seem to work, however.
<syntaxhighlight lang="powershell">
<lang PowerShell>
@'
"Country","Length","Example"
Line 3,887 ⟶ 4,015:
 
$ibans
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,940 ⟶ 4,068:
United Kingdom GB 22 GB29NWBK60161331926819
</pre>
<syntaxhighlight lang="powershell">
<lang PowerShell>
$regex = [regex]'[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{6}[0-9]{5}([a-zA-Z0-9]?){0,16}'
 
Line 3,951 ⟶ 4,079:
}
}
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 4,006 ⟶ 4,134:
 
=={{header|PureBasic}}==
<langsyntaxhighlight lang="purebasic">EnableExplicit
Enumeration IBAN
#IBAN_VAL
Line 4,097 ⟶ 4,225:
ForEver
Input()
End</langsyntaxhighlight>
{{out}}
<pre>
Line 4,116 ⟶ 4,244:
=={{header|Python}}==
{{trans|Ruby}}
<langsyntaxhighlight lang="python">import re
 
_country2length = dict(
Line 4,143 ⟶ 4,271:
if __name__ == '__main__':
for account in ["GB82 WEST 1234 5698 7654 32", "GB82 TEST 1234 5698 7654 32"]:
print('%s validation is: %s' % (account, valid_iban(account)))</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 validation is: True
GB82 TEST 1234 5698 7654 32 validation is: False
 
=={{header|Racket}}==
<langsyntaxhighlight lang="racket">#lang racket
(define lens
'([AL 28] [AD 24] [AT 20] [AZ 28] [BH 22] [BE 16] [BA 20] [BR 29] [BG 22]
Line 4,172 ⟶ 4,300:
 
(valid-iban? "GB82 WEST 1234 5698 7654 32") ; => #t
(valid-iban? "GB82 TEST 1234 5698 7654 32") ; => #f</langsyntaxhighlight>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" perl6line>subset IBAN of Str where sub ($_ is copy) {
s:g/\s//;
return False if m/<-[ 0..9 A..Z a..z ]alnum>/ or .chars != <
AD 24 AE 23 AL 28 AT 20 AZ 28 BA 20 BE 16 BG 22 BH 22 BR 29 CH 21
CR 21 CY 28 CZ 24 DE 22 DK 18 DO 28 EE 20 ES 24 FI 18 FO 18 FR 27
Line 4,194 ⟶ 4,322:
'GB82 WEST 1234 5698 7654 32',
'gb82 west 1234 5698 7654 32',
'GB82 TEST 1234 5698 7654 32';</langsyntaxhighlight>{{out}}
GB82 WEST 1234 5698 7654 32 is valid.
gb82 west 1234 5698 7654 32 is valid.
Line 4,202 ⟶ 4,330:
These REXX programs can validate an IBAN specified on the command line or from an internal list.
===basic checking===
<langsyntaxhighlight lang="rexx">/*REXX program validates an IBAN (International Bank Account Number). */
@.=; @.1 = 'GB82 WEST 1234 5698 7654 32 '
@.2 = 'Gb82 West 1234 5698 7654 32 '
Line 4,246 ⟶ 4,374:
 
if z//97==1 then return 0 /*check if correct remainder (modulus).*/
return e 'check digits.'</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 4,266 ⟶ 4,394:
:* checks for two countries that may not be valid (as per their entry date into the IBAN system)
:* checks some countries to make sure their check digits match a specific value
<langsyntaxhighlight lang="rexx">/*REXX pgm validates an IBAN (International Bank Account Number), including date ranges.*/
@.=; @.1 = 'GB82 WEST 1234 5698 7654 32 '
@.2 = 'Gb82 West 1234 5698 7654 32 '
Line 4,319 ⟶ 4,447:
 
if z//97==1 then return 0 /*check if correct remainder (modulus).*/
return e 'check digits.'</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input, &nbsp; (the run date of this program is &nbsp; 29-April-2013):}}
<pre>
Line 4,338 ⟶ 4,466:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : IBAN
 
Line 4,391 ⟶ 4,519:
modnew = number(modnew) % 97
return modnew
</syntaxhighlight>
</lang>
Output:
<pre>
Line 4,403 ⟶ 4,531:
=={{header|Ruby}}==
{{works with|Ruby|1.9+}}
<langsyntaxhighlight Rubylang="ruby">def valid_iban? iban
len = {
AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16, BH: 22, BA: 20, BR: 29,
Line 4,431 ⟶ 4,559:
 
p valid_iban? "GB82 WEST 1234 5698 7654 32" #=> true
p valid_iban? "GB82 TEST 1234 5698 7654 32" #=> false</langsyntaxhighlight>
 
=={{header|Rust}}==
<syntaxhighlight lang="rust">
<lang Rust>
fn main() {
for iban in [
Line 4,500 ⟶ 4,628:
}) == 1
}
</syntaxhighlight>
</lang>
 
=={{header|Scala}}==
{{libheader|Scala}}<langsyntaxhighlight Scalalang="scala">import scala.collection.immutable.SortedMap
 
class Iban(val iban: String) {
Line 4,547 ⟶ 4,675:
 
def apply(s: String) = new Iban(s.replaceAll( """\s""", ""))
}</langsyntaxhighlight>The test program:
<langsyntaxhighlight Scalalang="scala">object IbanTest extends App {
def blackCases = """AT611904300235473201
|GB82TEST12345698765432
Line 4,645 ⟶ 4,773:
blackCases.lines.foreach(l => assert(!Iban(l).isValidIban))
println(s"Successfully completed; ${whiteCases.lines.size + blackCases.lines.size} cases tested, no errors.")
}</langsyntaxhighlight>
{{out}}
Successfully completed; 91 cases tested, no errors.
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "bigint.s7i";
 
Line 4,706 ⟶ 4,834:
check("GB82 TEST 1234 5698 7654 32");
check("GB82 WEST 1243 5698 7654 32");
end func;</langsyntaxhighlight>
{{out}}
<pre>
Line 4,717 ⟶ 4,845:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">func valid_iban(iban) {
static len = Hash(
AD=>24, AE=>23, AL=>28, AO=>25, AT=>20, AZ=>28, BA=>20, BE=>16, BF=>27,
Line 4,747 ⟶ 4,875:
 
say valid_iban("GB82 WEST 1234 5698 7654 32") #=> true
say valid_iban("GB82 TEST 1234 5698 7654 32") #=> false</langsyntaxhighlight>
 
=={{header|SNOBOL4}}==
<langsyntaxhighlight SNOBOL4lang="snobol4">* IBAN - International Bank Account Number validation
DEFINE('ibantable()') :(iban_table_end)
ibantable
Line 4,830 ⟶ 4,958:
 
OUTPUT = "valid IBAN: " line :(read)
END</langsyntaxhighlight>
 
'''Output:'''
Line 4,850 ⟶ 4,978:
{{works with|SML/NJ}}
 
<langsyntaxhighlight lang="sml">(* country_code : string -> int *)
(* Get the length of a valid IBAN given the two chars long country code *)
fun country_code (str : string) : int =
Line 4,916 ⟶ 5,044:
IntInf.mod (number, 97) = 1
end
end handle Subscript => false | Domain => false</langsyntaxhighlight>
 
{{output}}
Line 4,925 ⟶ 5,053:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">proc verifyIBAN {iban} {
# Normalize by up-casing and stripping illegal chars (e.g., space)
set iban [regsub -all {[^A-Z0-9]+} [string toupper $iban] ""]
Line 4,958 ⟶ 5,086:
# Verify length and modulus
return [expr {[string length $iban] == $len && $num % 97 == 1}]
}</langsyntaxhighlight>Demonstrating:
<langsyntaxhighlight lang="tcl">set iban "GB82 WEST 1234 5698 7654 32"
puts "$iban is [expr {[verifyIBAN $iban] ? {verified} : {unverified}}]"
set not "GB42 WEST 1234 5698 7654 32"
puts "$not is [expr {[verifyIBAN $not] ? {verified} : {unverified}}]"</langsyntaxhighlight>{{out}}
<pre>GB82 WEST 1234 5698 7654 32 is verified
GB42 WEST 1234 5698 7654 32 is unverified</pre>
Line 4,969 ⟶ 5,097:
{{works with|bash}}
This does not verify the country code or the length.
<langsyntaxhighlight lang="bash">declare -A base36=(
[A]=10 [B]=11 [C]=12 [D]=13 [E]=14 [F]=15 [G]=16 [H]=17 [I]=18
[J]=19 [K]=20 [L]=21 [M]=22 [N]=23 [O]=24 [P]=25 [Q]=26 [R]=27
Line 5,002 ⟶ 5,130:
printf "%s : " "$test"
is_iban "$test" && echo yes || echo no
done</langsyntaxhighlight>
 
{{output}}
Line 5,009 ⟶ 5,137:
 
=={{header|VBA}}==
{{trans|Phix}}<langsyntaxhighlight lang="vb">Public nations As New Collection
Private Sub init()
nations.Add 24, "AD"
Line 5,088 ⟶ 5,216:
test "SA03 8000 0000 6080 1016 7519", True
test "CH93 0076 2011 6238 5295 7", True
End Sub</langsyntaxhighlight>{{out}}
<pre>GB82WEST12345698765432 ok
GB82TEST12345698765432 invalid (as expected)
Line 5,096 ⟶ 5,224:
 
=={{header|VBScript}}==
<syntaxhighlight lang="vb">
<lang vb>
Function validate_iban(s)
validate_iban = Chr(34) & s & Chr(34) & " is NOT valid."
Line 5,155 ⟶ 5,283:
WScript.StdOut.WriteLine validate_iban("US12 3456 7890 0987 6543 210")
WScript.StdOut.WriteLine validate_iban("GR16 0110 1250 0000 0001 2300 695X")
</syntaxhighlight>
</lang>
 
{{Out}}
Line 5,176 ⟶ 5,304:
{{trans|Kotlin}}
{{libheader|Wren-big}}
<langsyntaxhighlight ecmascriptlang="wren">import "./big" for BigInt
 
var countryCodes =
Line 5,213 ⟶ 5,341:
var valid = isValid.call(iban)
System.print(iban + (valid ? " may be valid" : " is not valid"))
}</langsyntaxhighlight>
 
{{out}}
Line 5,223 ⟶ 5,351:
=={{header|Yabasic}}==
{{trans|Phix}}
<langsyntaxhighlight Yabasiclang="yabasic">// List updated to release 72, 25 November 2016, of IBAN Registry (75 countries)
countryCodes$ = "AD24 AE23 AL28 AT20 AZ28 BA20 BE16 BG22 BH22 BR29 BY28 CH21 CR22 CY28 CZ24 DE22 "
countryCodes$ = countryCodes$ + "DK18 DO28 EE20 ES24 FI18 FO18 FR27 GB22 GE22 GI23 GL18 GR27 GT28 HR21 HU28 IE22 "
Line 5,295 ⟶ 5,423:
test("GB81 WEST 1234 5698 7654 32", false)
test("SA03 8000 0000 6080 1016 7519", true)
test("CH93 0076 2011 6238 5295 7", true)</langsyntaxhighlight>
 
=={{header|zkl}}==
Using GMP big nums:
<langsyntaxhighlight lang="zkl">var BN=Import("zklBigNum");
fcn validateIBAN(iban){
iban=iban-" \t";
alphaNums.matches(iban) and (ibans.find(iban[0,2])==iban.len()) and
( BN((iban[4,*]+iban[0,4]).apply("toInt",36)) % 97 == 1 )
}</langsyntaxhighlight>Without using big nums:
<langsyntaxhighlight lang="zkl">fcn validateIBAN(iban){
iban=iban-" \t";
alphaNums.matches(iban) and (ibans.find(iban[0,2])==iban.len()) and
Line 5,316 ⟶ 5,444:
}
M
}</langsyntaxhighlight><syntaxhighlight lang ="zkl">var alphaNums=RegExp("^[0-9A-Z]+$");
var ibans= // Dictionary("AD":24, ...)
("AD24 AE23 AL28 AO25 AT20 AZ28 BA20 BE16 BF27 BG22 BH22 BI16 "
Line 5,325 ⟶ 5,453:
"MR27 MT31 MU30 MZ25 NL18 NO15 PK24 PL28 PS29 PT25 QA29 RO24 "
"RS22 SA24 SE24 SI19 SK24 SM27 SN28 TN24 TR26 UA29 VG24")
.split(" ").pump(D(),fcn(w){return(w[0,2],w[2,*].toInt())});</langsyntaxhighlight>Testing 1 2 3
<langsyntaxhighlight lang="zkl"> // all valid
T("GB82 WEST 1234 5698 7654 32","GB82WEST12345698765432",
"GR16 0110 1250 0000 0001 2300 695","GB29 NWBK 6016 1331 9268 19",
Line 5,345 ⟶ 5,473:
...
"CH9300762011623852957").split()
.apply(validateIBAN).toString(*).println();</langsyntaxhighlight>
{{out}}
<pre>
Line 5,361 ⟶ 5,489:
=={{header|ZX Spectrum Basic}}==
{{trans|BBC BASIC}}
<langsyntaxhighlight lang="zxbasic">10 REM REM Used the following as official standard:
20 REM REM http://www.cnb.cz/cs/platebni_styk/iban/download/EBS204.pdf
30 REM REM Pairs of ISO 3166 country code & expected IBAN length for this country
Line 5,424 ⟶ 5,552:
4050 NEXT i
4060 RETURN
5000 DEF FN m(a,b)=a-INT (a/b)*b: REM modulo</langsyntaxhighlight>
9,476

edits