最近發現自己對數論幾乎是一竅不通。是時候開始學了。從零開始……判斷一個數是否為質數:
bool prime(int a) { for(int i=2;i<=sqrt(a);i++) { if(a%i==0) return false; } return true; }