Clean code

This commit is contained in:
daniele 2019-09-19 16:53:36 +02:00
parent 0f038c1abc
commit 01cae6fff0
Signed by: fuxino
GPG Key ID: 6FE25B4A3EE16FDA
3 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ int main(int argc, char **argv)
{
int grid[][20] = {{8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8},
{49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0},
{81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65},
{81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3, 49, 13, 36, 65},
{52, 70, 95, 23, 4, 60, 11, 42, 69, 24, 68, 56, 1, 32, 56, 71, 37, 2, 36, 91},
{22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80},
{24, 47, 32, 60, 99, 3, 45, 2, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50},

View File

@ -14,7 +14,7 @@ int main(int argc, char **argv)
clock_gettime(CLOCK_MONOTONIC, &start);
for(i = 1; i< 1000000; i++)
for(i = 1; i < 1000000; i++)
{
count = collatz_length(i);
collatz_found[i] = count;

View File

@ -109,18 +109,18 @@ int *sieve(int n)
int count_divisors(int n)
{
int i, top, count = 0;
int i, limit, count = 0;
top = floor(sqrt(n));
limit = floor(sqrt(n));
for(i = 1; i < top; i++)
for(i = 1; i < limit; i++)
{
if(n % i == 0)
{
count += 2;
}
if(n == top * top)
if(n == limit * limit)
{
count--;
}