And after all I'm talking about programming only not about stupid things
You know, to do it in a single line you are likely required to generate a string representation of the number to iterate over all the single digits. This is inefficient and probably no good solution. Why do you need to have a one-liner?
bool isA(const int n) {
return n == 0 || n == 1 || n == 153 || n == 370 || n == 371 || n == 407;
}
bool isA2(const int n) {
int sum = 0;
for (int num = n; num; num /= 10) {
const int r = num % 10;
sum += r * r * r;
}
return n == sum;
}
olli
Mihail
@MTRIX0
Samuel
BinaryByter
Roxifλsz 🇱🇹
klimi