Korean, Edit

C 言語の整数因数分解

上位カテゴリ : C言語


a. GitHub



「」c #include #include /* このソースは整数因数分解用です */

int main(int argc, char *argv[]) { int n; scanf(“%d”, &n); int i = 2; // “1” は素数ではないので、”2” から始めるのが妥当です while(1){ if(n == 1) ブレーク; if(n % i == 0){ printf(“%d “, i); n = n / i; 私 - ; // 素数は与えられた数を何度も割ることができます } i++; } 0を返します。 } 「」



入力: 2016.02.16 13:15

results matching ""

    No results matching ""