/****************************************************************************** * * * DIRICHLET CHARACTERS * * 04/02/10 (dkc) * * * ******************************************************************************/ #include <math.h> double dirchar(unsigned int a, unsigned int p) { unsigned int i,r; int s; r=a-(a/p)*p; if (r==0) return(0.0); for (i=1; i<p; i++) { s=(int)i*(int)i-(int)r; if (s==(s/(int)p)*(int)p) return(1.0); } return(-1.0); }