new 4.3BSD Unix Internals book

Edwin Kremer edwin at ruuinf.UUCP
Tue Jan 31 18:54:41 AEST 1989


In article <9515 at nsc.nsc.com>, glennw at nsc.nsc.com (Glenn Weinberg) writes:
> In article <2248 at unmvax.unm.edu> mike at turing.cs.unm.edu (Michael I. Bushnell) writes:
> >In article <362 at microsoft.UUCP> w-colinp at microsoft.uucp (Colin Plumb) writes:
> >
> I don't remember the check algorithm off the top of my head.  Learned all
> this junk back in a computer science course a long time ago, believe it
> or not.
> 

The check algorithm for ISBN numbers is:

	check_isbn(isbn_nr)
	{
		mulfac = 1;			/* multiplication factor   */
		sum = 0;
		FOREACH digit in isbn_nr	/* start at leftmost digit */
		DO
			sum += digit * mulfac;
			++mulfac;
		DONE
		if ( sum % 11 == 0 )		/* can we divide by 11 ??  */
			return( TRUE );
		else return( FALSE );
	}


Needless to say this is rather sloppy code, but i hope it's clear
enough to get the point...
Please remember that the last 'digit' may be an 'X',
denoting a value of 10 !!!
							--[ Edwin ]--
-- 
Edwin Kremer, Department of Computer Science, University of Utrecht
Padualaan 14,  P.O. Box 80.089,  3508 TB  Utrecht,  The Netherlands
Phone: +31 - 30 - 534104        |  UUCP    : ...!hp4nl!ruuinf!edwin
    "I speak for myself ..."    |  INTERNET: edwin at cs.ruu.nl



More information about the Comp.unix.wizards mailing list