ca =: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   d=: +/"1 ] 10 10 #: 1 2 */ i.#ca
   $d
2 36
   >./"1 d
11 14
   +/ 8 $ >./"1 d
100
   +/ 8 $ >./"1 +/"1 ] 10 10 #: 1 2 */ i.#ca
100

The columns of d are the sums of digits for each character of 
the alphabet ca, with 0{d for characters in even positions and 
1{d for characters in odd positions.  11 is the maximum SOD 
for the even characters and 14 is the maximum for the odd ones.
The maximum sum for an 8-character CUSIP is therefore 100,
and the required length for ct in sum{ct is 101.



----- Original Message -----
From: Arie Groeneveld <[EMAIL PROTECTED]>
Date: Wednesday, August 6, 2008 7:02
Subject: Re: [Jprogramming] CUSIP (was: Check digit utility)
To: Programming forum <[email protected]>

> Pfff...., still not good enough (LATT), it should be indeed 101 
> and not 
> 97 because of:
> 
>    ccd4 'TYTYTYTY'
> |index error: ccd4
> |       ccd4'TYTYTYTY'
> 
> > cna =: 97 $ '0987654321'
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to