Minor corrections
This commit is contained in:
parent
ec1d1fa446
commit
68b33e946c
5
C/p041.c
5
C/p041.c
@ -50,6 +50,11 @@ int count_digits(int n)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while(n > 0)
|
while(n > 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
5
C/p057.c
5
C/p057.c
@ -67,6 +67,11 @@ int count_digits(mpz_t n)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
mpz_t value;
|
mpz_t value;
|
||||||
|
|
||||||
|
if(mpz_cmp_ui(n, 0) == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
mpz_init_set(value, n);
|
mpz_init_set(value, n);
|
||||||
|
|
||||||
while(mpz_cmp_ui(value, 0))
|
while(mpz_cmp_ui(value, 0))
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from timeit import default_timer
|
from timeit import default_timer
|
||||||
|
|
||||||
# Function using a modified sieve of Eratosthenes to count
|
# Function using a modified sieve of Eratosthenes to count
|
||||||
# the prime factors of each number.
|
# the distinct prime factors of each number.
|
||||||
def count_factors(n):
|
def count_factors(n):
|
||||||
factors = [0] * n
|
factors = [0] * n
|
||||||
i = 2
|
i = 2
|
||||||
|
@ -82,7 +82,7 @@ def main():
|
|||||||
|
|
||||||
end = default_timer()
|
end = default_timer()
|
||||||
|
|
||||||
print('Project Euler, Problem 59')
|
print('Project Euler, Problem 60')
|
||||||
print('Answer: {}'.format(n))
|
print('Answer: {}'.format(n))
|
||||||
|
|
||||||
print('Elapsed time: {:.9f} seconds'.format(end - start))
|
print('Elapsed time: {:.9f} seconds'.format(end - start))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user