用for-loop要注意終止條件(sum>m)要寫在迴圈裡面,否則當m<0,就不會進入迴圈(如果持續條件寫sum>=m)。
for(int i=n; ; i++){ sum+=i; count++; if(sum>m){ break; } }