Ejemplo n.º 1
0
unsigned long main(void)
{
	unsigned long t = 285;
	unsigned long p = 165;
	unsigned long h = 143;
	t++;
	unsigned long tri = getTriangular(t);
	unsigned long pen = getPentagonal(t);
	unsigned long hex = getHexagonal(t);
	while (tri!=pen || tri!=hex)
	{
		if (pen < hex && pen < tri)
		{
			p++;
			pen = getPentagonal(p);
		}else if (hex < pen && hex < tri)
		{
			h++;
			hex = getHexagonal(h);
		}else
		{
			t++;
			tri = getTriangular(t);
		}
	}
	printf("t: %d, h: %d, p: %d, val: %d\n", t,h,p,tri);
	return 0;
}
Ejemplo n.º 2
0
int64_t Problem45::solve()
{
    int start = HEXAGONAL_START;
    while(++start)
    {
        if(isPentagonal(getHexagonal(start)))
            break;
    }
    
    return getHexagonal(start);
}