Hello guys, i am trying to solve Project eular problem-20 :"Find the sum of the digits in the number 100!".So i downloaded and included gmp libary for big integer.This is my code:
Code:
#include <stdio.h>
#include <mpir.h>
int main()
{
unsigned long s=0;
mpz_t result;
mpz_init (result);
mpz_fac_ui (result,10);
while(result>0) //untill here everything works fine
{
s+=mpz_tdiv_r_ui (result, result, 10);
mpz_tdiv_q_ui (result, result, 10);
}
printf ("%lu", s);
return 0;
}
I am definetly having problems with while loop and instructions in it,and i just dont know how to solve it. The reason why i used 10!, its just a test.
Thank you for your time.