#!/bin/bash #et -x #number=$$(echo '10 ^ (10 ^ 8 - 1) + 13' | bc | sed 's/\\$$//' | tr -d '\012'); echo "AKS($$number)" | gp aks.gp number=$(echo "$@" | bc | sed 's/\\$$//' | tr -d '\012') #result=$(echo "AKS($number)" | gp aks.gp 2>&1 | egrep '^%1 = ' | sed 's/^%1 = //') result=$(echo "AKS($number)" | gp -q --emacs -s $((2**30)) aks.gp | head -3 | tail -1) case "$result" in 0) echo "$@" is composite exit 0 ;; 1) echo "$@" is prime exit 0 ;; *) echo "$0: internal error" 1>&2 exit 1 ;; esac