diff options
Diffstat (limited to '2.3-1/src/c/elementaryFunctions/discrete_mathematics')
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c | 9 | ||||
-rw-r--r-- | 2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c | 13 |
2 files changed, 8 insertions, 14 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c index 98019431..9ac76b5a 100644 --- a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c +++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/dfactors.c @@ -18,17 +18,15 @@ void dfactors(double in,double* out) int n=(int)in; while (n%2 == 0) { - //printf("%d ", 2); - out[k++]=2; + out[k++]=2; n = n/2; } - for (i = 3; i <= sqrt(n); i = i+2) + for (i = 3; i <= (int)sqrt((double)n); i = i+2) { while (n%i == 0) { - out[k++]=i; - //printf("%d ", i); + out[k++]=i; n = n/i; } } @@ -36,7 +34,6 @@ void dfactors(double in,double* out) if (n > 2) { out[k++]=n; - //printf ("%d ", n); } } diff --git a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c index 2e5ba478..a2eed09f 100644 --- a/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c +++ b/2.3-1/src/c/elementaryFunctions/discrete_mathematics/factor/sfactors.c @@ -18,25 +18,22 @@ void sfactors(float in,float* out) int n=(int)in; while (n%2 == 0) { - //printf("%d ", 2); - out[k++]=2; + out[k++]=2; n = n/2; } - for (i = 3; i <= sqrt(n); i = i+2) + for (i = 3; i <= (int)sqrt((double)n); i = i+2) { while (n%i == 0) { - out[k++]=i; - //printf("%d ", i); + out[k++]=i; n = n/i; } } - if (n > 2) + if (n > 2) { out[k++]=n; - //printf ("%d ", n); - } + } } |