codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> int factor_num(int n){ int i=2, cnt=0; while(n!=1){ while(n%i==0){ n /= i; cnt++; } i++; } return cnt; } int main(void){ int a[100], b[100], i=0, j=0, max, midx; do{ printf("Input number ? (smaller than 2: quit) "); scanf("%d", &a[i]); i++; } while (a[i-1]>=2); for(j=0;j<i-1;j++){ b[j]=factor_num(a[j]); } max = b[0], midx=0; for(j=0;j<i-1;j++){ if(max<b[j]) max=b[j], midx=j; } printf("max : %d when %d\n", max, a[midx]); }
Private
[
?
]
Run code
Submit