# Thread: My homework c project (help)

1. Originally Posted by john.c I vote to not explain it to him. If he can't figure it out from what's been given so far then that's too bad. I agree that there's is surely enough written here to see the pattern now. I do wonder what the homework is for (school?/uni?/subject?) though because it's not really about programming at the end of the day (Edit: that was a stupid thing for me to say; of course it's programming because problem solving is what programming is). After replacing my prime sieve with trial division (there's so few primes involved I dunno why I bothered with a sieve in the first place) my entire program is 20 lines long :/ 2. ##  Originally Posted by john.c I vote to not explain it to him. If he can't figure it out from what's been given so far then that's too bad. I solved the problem by own way but it is very slow. How can i get to the conclusion faster? it takes about 4 hours. At least answer this. MY CODE:
insert
Code:
```#include<stdio.h>
#include<stdlib.h>
#include<math.h>
unsigned long long int gcd(unsigned long long int n, unsigned long long int b);

int main()
{

unsigned long long int n, b = 13, gn = 0;

printf("Enter n:");
scanf_s("%llu", &n);

if (n < 4)
{
printf("\nERROR!!\n");
}
else if (n == 4)
printf("\n g(%llu): 13\n", n);

else if (n == 5)

gn = b + gcd(n, b);

else
for (unsigned long long int i = 5; i < n; i++)
{
b = b + gcd(i, b);
gn = b + gcd(i+1, b);
}

printf("\n%llu\n", gn);

printf("\n\n");
system("pause");
}
unsigned long long int gcd(unsigned long long int n, unsigned long long int b)
{
if (b == 0)
return n;
else
return gcd(b, n % b);
}``` 3. @muhammetekurt I can take you through it, but you'd probably be better reading the discussion forum regarding the problem on Project Euler because you can then see different perspectives and even formal proofs.

Edit: vbulletin keeps parsing my URLs even when I click do not automatically parse urls :/ If the two links below don't work, the second is (without the https prefix) projecteuler.net/thread=443

Edit 2: Is this really homework? If so, homework for what? Also, did you graph the output (of the test values on the first page of this thread) as suggested?

a) sign up for Project Euler, put in your answer for problem 443: Problem 443 - Project Euler
b) after it says yay you got it right, visit the discussion forum (after you solve the problem you can get the link to the discussion thread from the problem page): Sign In - Project Euler Popular pages Recent additions #### Tags for this Thread

find, g1000, g10^15, gn-1, problem 