blob: b0d86beac1391e900a855faf942839cc73c6bd67 (
plain)
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
|
#include<iostream>
#include<math.h>
bool nombreeligible ( int n) {
int som=0,cpt =1, act=0, puiss=0;
act = n;
while ( n > 10 ) {
n= n/10;
cpt ++;
}
for ( int i=cpt; i >= 0; i--) {
puiss = (int) pow(10,i);
som += (int)pow((act/puiss)%10,3);
}
return som==act ? true : false ;
}
bool tripleteligible ( int a, int b, int c) {
int n = a*100 + b*10 + c;
return n == pow(a,3) + pow (b,3) + pow(c,3);
}
void testeentier () {
for (int i = 2; i < 1000; i ++) {
if(nombreeligible(i)) {
std::cout << i << std::endl;
}
}
}
int main () {
testeentier();
return 0;
}
|