Jump to content

CUSIP: Difference between revisions

1,004 bytes added ,  2 years ago
Added 11l
(Added 11l)
Line 49:
* [[Validate_International_Securities_Identification_Number|ISIN]]
<br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F cusip_check(=cusip)
I cusip.len != 9
X ValueError(‘CUSIP must be 9 characters’)
 
cusip = cusip.uppercase()
V total = 0
L(i) 8
V v = 0
V c = cusip[i]
I c.is_digit()
v = Int(c)
E I c.is_alpha()
V p = c.code - ‘A’.code + 1
v = p + 9
E I c == ‘*’
v = 36
E I c == ‘@’
v = 37
E I c == ‘#’
v = 38
 
I i % 2 != 0
v *= 2
 
total += v I/ 10 + v % 10
V check = (10 - (total % 10)) % 10
R String(check) == cusip.last
 
V codes = [‘037833100’,
‘17275R102’,
‘38259P508’,
‘594918104’,
‘68389X106’,
‘68389X105’]
L(code) codes
print(code‘: ’(I cusip_check(code) {‘valid’} E ‘invalid’))</lang>
 
{{out}}
<pre>
037833100: valid
17275R102: valid
38259P508: valid
594918104: valid
68389X106: invalid
68389X105: valid
</pre>
 
=={{header|360 Assembly}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.