Multiplicatively perfect numbers: Difference between revisions

→‎{{header|C}}: Changed to include '1' as an MPN.
(→‎{{header|Wren}}: Changed to include '1' as an MPN.)
(→‎{{header|C}}: Changed to include '1' as an MPN.)
Line 19:
 
=={{header|C}}==
This includes '1' as an MPN.
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdbool.h>
Line 61 ⟶ 62:
setlocale(LC_NUMERIC, "");
for (i = 0; ; ++i) {
divisorsif (i, divs,!= &length1); {
divisors(i, divs, &length);
} else {
divs[1] = divs[0] = 1;
length = 2;
}
if (length > 1) {
prod = 1;
Line 73 ⟶ 79:
}
}
if (i == 499) printf("\n\n");
if (i >= limit - 1) {
for (j = s; j * j < limit; j += 2) if (isPrime(j)) ++squares;
for (k = c; k * k * k < limit; k +=2 ) if (isPrime(k)) ++cubes;
t = count + squares - cubes - 1;
printf("Counts under %'7d: MPNs = %'7d Semi-primes = %'7d\n", limit, count, t);
if (limit == 500000) break;
Line 91 ⟶ 97:
<pre>
Multiplicatively perfect numbers under 500:
1 6 8 10 14 15 21 22 26 27 33
33 34 35 38 39 46 51 55 57 58 62
62 65 69 74 77 82 85 86 87 91 93
93 94 95 106 111 115 118 119 122 123 125
125 129 133 134 141 142 143 145 146 155 158
158 159 161 166 177 178 183 185 187 194 201
201 202 203 205 206 209 213 214 215 217 218
218 219 221 226 235 237 247 249 253 254 259
259 262 265 267 274 278 287 291 295 298 299
299 301 302 303 305 309 314 319 321 323 326
326 327 329 334 335 339 341 343 346 355 358
358 362 365 371 377 381 382 386 391 393 394
394 395 398 403 407 411 413 415 417 422 427
427 437 445 446 447 451 453 454 458 466 469
469 471 473 478 481 482 485 489 493 497
 
Counts under 500: MPNs = 149150 Semi-primes = 153
Counts under 5,000: MPNs = 1,353354 Semi-primes = 1,365
Counts under 50,000: MPNs = 12,073074 Semi-primes = 12,110
Counts under 500,000: MPNs = 108,222223 Semi-primes = 108,326
</pre>
 
9,488

edits