-2
任何人都可以給我一些見解,我將如何去做一個簡單的程序在C中,當我輸入例如數字16(代表程序會計算從1-100000開始有多少值恰好有16個因子。 我剛剛開始使用C,所以請詳細說明並使用相當簡單的方法。在一定範圍內具有x個因子數的C數量
到目前爲止,我已經做到了這一點:
#include <stdio.h>
int main(void)
{
int n,x=1,y=100000,factors,count;
printf(the number of factors:\n");
scanf("%d",&n);
for(factors=0;factors<=1;factors++){
if(x%factors==0&&y%factors==0){
count++;
}
}
printf("There are %d numbers between 1 and 100000 inclusive which have exactly %d divisors\n",
n,factors);
return 0;
}
http://stackoverflow.com/questions/26587512/counting-positive-integers-with-a-given-number-of-divisors – BLUEPIXY 2014-10-27 23:45:35