valid_cusip = proc (s: string) returns (bool) own chars: string := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#" if string$size(s) ~= 9 then return(false) end sum: int := 0 for i: int in int$from_to(1,8) do v: int := string$indexc(s[i], chars)-1 if v<0 then return(false) end if i//2=0 then v := v*2 end sum := sum + v/10 + v//10 end check: int := (10 - sum // 10) // 10 return(check = string$indexc(s[9], chars)-1) end valid_cusip start_up = proc () po: stream := stream$primary_output() cusips: array[string] := array[string]$[ "037833100", "17275R102", "38259P508", "594918104", "68389X106", "68389X105" ] for cusip: string in array[string]$elements(cusips) do stream$puts(po, cusip || ": ") if valid_cusip(cusip) then stream$putl(po, "valid") else stream$putl(po, "invalid") end end end start_up