Mod 97 procedure in F#
#light
module Mod97=
open System
//split the input string in chunks of length 11 (or less)
let noIter (inputString:string)=Convert.ToInt32(Math.Round(0.49+ Convert.ToDouble(inputString.Length)/11.0,0))
let maxLen num=if num>=11 then 11 else num
let split11 (inputString:string)=List.init (noIter inputString) (fun i->
inputString.Substring(11*i,(maxLen ((inputString.Length - 11*i)))) )
//power function
let powDec (n:int) (x:int)= Convert.ToDouble( Math.Pow( Convert.ToDouble(x) ,Convert.ToDouble(n)))
//remaind function
let rem (num:double) =
let num97=(num)*100.0/97.0
num97-(Math.Truncate(num97))
//division procedure, p.e. 9931= 100*97 +2*100+31; 231=2*97+37;
//100*37/97=38.14, remainder=14, 98-14=84; mod97=84
let remainder inputString=
let remaind split11 inputString=List.fold_left (fun (acc:double) (h:string)-> rem ((Math.Round( acc*97.0,0)*
(powDec (h. Length-2) 10))+Convert.ToDouble(h))) 0.0 (split11 inputString)
((98.0-Math.Round((remaind split11 inputString)*97.0,0)).ToString ())
Avtors: Josip Zohil, Velibor Djukić, Miloš Pantić