fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. int main() {
  6. auto const check = [] (std::size_t const value) {
  7. std::size_t cypherSum = 0;
  8. for (auto const cypher : std::to_string(value)) {
  9. cypherSum += cypher - '0';
  10. }
  11.  
  12. return value == cypherSum * cypherSum * cypherSum;
  13. };
  14.  
  15. std::size_t const intervalBegin = 0;
  16. std::size_t const intervalEnd = 100000;
  17.  
  18. for (auto value = intervalBegin; value <= intervalEnd; ++value) {
  19. if (check(value)) {
  20. std::cout << value << std::endl;
  21. }
  22. }
  23. }
  24.  
Success #stdin #stdout 0.03s 3428KB
stdin
Standard input is empty
stdout
0
1
512
4913
5832
17576
19683