Multi-base primes: Difference between revisions

m
C++ performance improvement
m (C++ - specify CPU model)
m (C++ performance improvement)
Line 45:
 
=={{header|C++}}==
Originally translated from [[#Wren|Wren]] with ideas borrowed from other solutions.
{{trans|Wren}}
The maximum base and number of characters can be specified as command line arguments.
<lang cpp>#include <algorithm>
Line 129:
bases.clear();
for (unsigned int b = min_base; b <= max_base; ++b) {
if (max_base - b + 1 + bases.size() < most_bases)
break;
uint64_t n = 0;
for (auto d : digits)
Line 174 ⟶ 176:
 
{{out}}
Maximum base 36 and maximum length 6. This takes 0.76 seconds to process up to 5 character strings and 2927 seconds to process up to 6 characters (3.2GHz Intel Core i5-4570).
<pre>
1-character strings which are prime in most bases: 34
Line 199 ⟶ 201:
</pre>
 
Maximum base 62 and maximum length 5. This takes 0.2516 seconds to process up to 4 character strings and 1511 seconds to process up to 5 characters (3.2GHz Intel Core i5-4570).
<pre>
1-character strings which are prime in most bases: 60
1,777

edits