2018/5/14程式作業 第4題 for 四子一丙
#include #include int main(void) { int ipp = 0, ix = 2, iTF = 0; float sum = 0, product = 1; printf("請輸入正整數"); scanf("%d", &ipp); if(ipp < 2 || ipp > 99999) { printf("您輸入的值太大了喔\n"); } else { while(ix <= ipp) { if(ipp%ix == 0) { sum += ix; product *= ix; iTF = 1; } ix++; } printf("所有因數和為%.0f\n所有因數積為%.0f\n", sum, product); } system("pause"); return(0); }
留言
張貼留言