Number theory oriented calculation system