-
Notifications
You must be signed in to change notification settings - Fork 0
/
eu0045.cpp
57 lines (46 loc) · 1.31 KB
/
eu0045.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include"eu0045.h"
#include"principal.h"
void eu0045 :: solucion(){
// ---------------------------------------------------- //
tstart = (double)clock()/CLOCKS_PER_SEC;
// ---------------------------------------------------- //
output = 0;
// ---------------------------------------------------- //
temp_1 = 3; // T2
temp_2 = 2; // n para T
temp_3 = 5; // P2
temp_4 = 2; // n para P
temp_5 = 6; // H2
temp_6 = 2; // n para H
temp_7 = 0; // Contador de las veces q ha entrado, la segunda es la vencida
// Un loop infinito hasta q el pentagonar sea mayor (o igual) q al exagonar, y luego cuando el triagunarl
// sea mayor (o igual) que el pentagonal, al final pruba si todos son iguales.
while(1){
temp_6++;
temp_5 = temp_6*(2*temp_6-1);
while( temp_5>temp_3 ){
temp_4++;
temp_3 = temp_4*(3*temp_4-1)/2;
}
while( temp_3>temp_1 ){
temp_2++;
temp_1 = temp_2*(temp_2+1)/2;
}
if( temp_5==temp_3 && temp_3==temp_1 ){
temp_7++;
if( temp_7==2 ){
output = temp_5;
break;
}
}
}
// ---------------------------------------------------- //
tstop = (double)clock()/CLOCKS_PER_SEC;
ttime= tstop-tstart;
// ---------------------------------------------------- //
}
void eu0045 :: printsolution(){
cout << "Euler 0045\n";
cout << "Time: " << ttime << "\n";
cout << output;
}