################################ # SCRIPT: qr_find.bdscr [v2.0] # ################################ # 2813 is a quadratic residue mod 9907 but 1001 is not. p=9907 print("p=",p,"\n") # Outer loop for two values of n... for n in (2813,1001) do println("Testing n=",n,"..."); for x in (2..p-1) do q=(modexp(x,2,p)==n); breakif (q) done; if(q) then printf("%d is a QR mod %d since %d^2=%d (mod %d)\n", n, p, x, modexp(x,2,p),p); else printf("%d is NOT a QR mod %d\n", n, p); fi done ? "ALL DONE"