Super-d numbers: Difference between revisions

Line 26:
:* '''[http://mathworld.wolfram.com/Super-dNumber.html Wolfram MathWorld - Super-d Number]'''
:* '''[http://oeis.org/A014569 OEIS: A014569 - Super-3 Numbers]'''
 
=={{header|C++}}==
{{trans|D}}
There are insufficiant bits avaiolable to calculate the super-5 or super-6 numbers without a biginteger library
<lang cpp>#include <iostream>
#include <sstream>
#include <vector>
 
uint64_t ipow(uint64_t base, uint64_t exp) {
uint64_t result = 1;
while (exp) {
if (exp & 1) {
result *= base;
}
exp >>= 1;
base *= base;
}
return result;
}
 
int main() {
using namespace std;
 
vector<string> rd{ "22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999" };
 
for (uint64_t ii = 2; ii < 5; ii++) {
cout << "First 10 super-" << ii << " numbers:\n";
int count = 0;
 
for (uint64_t j = 3; /* empty */; j++) {
auto k = ii * ipow(j, ii);
auto kstr = to_string(k);
auto needle = rd[(size_t)(ii - 2)];
auto res = kstr.find(needle);
if (res != string::npos) {
count++;
cout << j << ' ';
if (count == 10) {
cout << "\n\n";
break;
}
}
}
}
 
return 0;
}
</lang>
{{out}}
<pre>First 10 super-2 numbers:
19 31 69 81 105 106 107 119 127 131
 
First 10 super-3 numbers:
261 462 471 481 558 753 1036 1046 1471 1645
 
First 10 super-4 numbers:
1168 4972 7423 7752 8431 10267 11317 11487 11549 11680</pre>
 
=={{header|D}}==
1,452

edits