Exemplo n.º 1
0
int main(int argc, char **argv)
{
    mpz_t counter;
    mpz_t triangleValue;
    unsigned int factors;
    unsigned int previousFactors = 0;
    mpz_init_set_ui(counter, 1);
    mpz_init(triangleValue);
    mpz_init_set_ui(previousTriangleCounter, 0);
    
    while (1) 
    {
        nextTriangle(triangleValue);
        factors = factorCount(triangleValue);
        if (previousFactors < factors)
        {
            previousFactors = factors;
            printf("Number %s has triangle %s and %d factors\n", mpz_get_str(NULL, 10, counter), mpz_get_str(NULL, 10, triangleValue), factors);
        }
        if (factors >= STOP_COUNT)
            break;
        mpz_add_ui(counter, counter, 1);
    }
    return 0;
}
Exemplo n.º 2
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main ()
{
    long triangle = 1;
    int index = 1;
    while (factorCount (triangle) < 1001)
    {
        index ++;
        triangle += index;
    }
    printf ("%ld\n", triangle);
}
int problem(int argc, char** argv) {

	int triangleNum = 1;
	int num = 1;
	int count = 0;

	while( 1 ) {
		num++;
		triangleNum += num;
		count = factorCount(triangleNum);
		// printf("num = %6d; Tn = %8d; count = %4d;\n", num, triangleNum, count);
		if( count >= 500 ) {
			break;
		}
	}

	printf("num = %d; triangleNum = %d; count = %d;\n", num, triangleNum, count);
	factorPrint(triangleNum);

	return( 0 );
}