# @(#) $Revision: 1.3 $ # @(#) RCS control in //prime.corp/usr/local/src/cmd/prime/src/chkcomp.awk # # Copyright (C) 1997 Landon Curt Noll, all rights reserved. # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose is hereby granted, provided that # the above copyright, this permission notice, and the disclaimer # below appear in all of the following: # # * supporting documentation # * source copies # * source works derived from this source # # THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO # EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # # Landon Curt Noll /\oo/\ # # chongo@{toad,sgi}.com Share and Enjoy! # BEGIN { print "define t(q,n,k,x) { return ((pmod(2,n,q)*k)+x)%q; }"; print "cnt=0;"; print "err=0;"; } NF == 4 { print "++cnt;"; print "if (t(" $1 "," $2 "," $3 "," $4 ") != 0) {"; if ($4 > 0) { x="+1"; } else { x="-1"; } print " print", "'(':" $3 ":'*(2^':" $2 ":')" x ") % ':" $1 ", '==', t(" $1 "," $2 "," $3 "," $4 ");"; print " ++err;"; print "}"; } END { print "print cnt, 'composites sieved with', err, 'errors';"; }