-
Notifications
You must be signed in to change notification settings - Fork 0
/
eu0012.cpp
51 lines (43 loc) · 1.21 KB
/
eu0012.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
#include"eu0012.h"
#include"principal.h"
void eu0012 :: solucion(){
// ---------------------------------------------------- //
tstart = (double)clock()/CLOCKS_PER_SEC;
// ---------------------------------------------------- //
output = 0;
// ---------------------------------------------------- //
temp_1 = 1; //numero triangular
temp_2 = 1; //numero q se anade cada ciclo (1,2,3,4,5,...)
temp_3 = 1; //cantida de multiplos
temp_5 = 1; //copia del numero triangular
temp_6 = 1; //factor de primos (m+1)
temp_7 = 1; //numero por el q se va dividiendo (se comprueba primero si e primo)
while( temp_3 <= 500 ){
temp_3 = 1;
temp_5 = temp_1;
temp_7 = 2;
while( temp_5 != 1 ){
temp_6 = 1;
if( isprime(&temp_7) ){
while( temp_5 % temp_7 == 0 ){
temp_5 = temp_5/temp_7;
temp_6++;
}
}
temp_3 = temp_3*temp_6;
temp_7++;
}
temp_2++;
temp_1+=temp_2;
}
output = temp_1-temp_2;
// ---------------------------------------------------- //
tstop = (double)clock()/CLOCKS_PER_SEC;
ttime= tstop-tstart;
// ---------------------------------------------------- //
}
void eu0012 :: printsolution(){
cout << "Euler 0012\n";
cout << "Time: " << ttime << "\n";
cout << output;
}