Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!ruuinf!edwin From: edwin@ruuinf.UUCP (Edwin Kremer) Newsgroups: comp.unix.wizards Subject: Re: new 4.3BSD Unix Internals book Summary: The check algorithm is easy and I do remember although is was some time ago for me too :-) Keywords: ISBN Message-ID: <1094@ruuinf.UUCP> Date: 31 Jan 89 08:54:41 GMT References: <568041@vaxa.uwa.oz> <362@microsoft.UUCP> <2248@unmvax.unm.edu> <9515@nsc.nsc.com> Organization: Univ of Utrecht, Dept of CS Lines: 36 In article <9515@nsc.nsc.com>, glennw@nsc.nsc.com (Glenn Weinberg) writes: > In article <2248@unmvax.unm.edu> mike@turing.cs.unm.edu (Michael I. Bushnell) writes: > >In article <362@microsoft.UUCP> w-colinp@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@cs.ruu.nl