Multiplicatively perfect numbers: Difference between revisions

(Undo revision 341817 by Petelomax (talk))
Tag: Undo
Line 173:
{{ (, (adjSemiPrime y)+]) +/isMPerfect i.y}} 500000
108223 108326</syntaxhighlight>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">using Printf
using Primes
 
 
""" Find and count multiplicatively perfect integers up to thresholds """
function testmultiplicativelyperfects(thresholds = [500, 5000, 50_000, 500_000])
mpcount, scount = 0, 0
pmask = primesmask(thresholds[end])
println("Multiplicatively perfect numbers under $(thresholds[begin]):")
for n in 1:thresholds[end]
f = factor(n).pe
flen = length(f)
if flen == 2 && f[1][2] == 1 == f[2][2] || flen == 1 && f[1][2] == 3
mpcount += 1
if n < thresholds[begin]
@printf("%3d * %3d = %3d ", f[1][1], n ÷ f[1][1], n)
mpcount % 5 == 0 && println()
end
end
if n in thresholds
cbsum, sqsum = sum(pmask[1:Int(floor(n^(1/3)))]), sum(pmask[1:isqrt(n)])
scount = mpcount - cbsum + sqsum
@printf("\nCounts under %d: MPNs = %7d Semi-primes = %7d\n", n, mpcount, scount)
end
end
end
 
testmultiplicativelyperfects()
</syntaxhighlight>{{out}}
<pre>
 
Multiplicatively perfect numbers under 500:
2 * 3 = 6 2 * 4 = 8 2 * 5 = 10 2 * 7 = 14 3 * 5 = 15
3 * 7 = 21 2 * 11 = 22 2 * 13 = 26 3 * 9 = 27 3 * 11 = 33
2 * 17 = 34 5 * 7 = 35 2 * 19 = 38 3 * 13 = 39 2 * 23 = 46
3 * 17 = 51 5 * 11 = 55 3 * 19 = 57 2 * 29 = 58 2 * 31 = 62
5 * 13 = 65 3 * 23 = 69 2 * 37 = 74 7 * 11 = 77 2 * 41 = 82
5 * 17 = 85 2 * 43 = 86 3 * 29 = 87 7 * 13 = 91 3 * 31 = 93
2 * 47 = 94 5 * 19 = 95 2 * 53 = 106 3 * 37 = 111 5 * 23 = 115
2 * 59 = 118 7 * 17 = 119 2 * 61 = 122 3 * 41 = 123 5 * 25 = 125
3 * 43 = 129 7 * 19 = 133 2 * 67 = 134 3 * 47 = 141 2 * 71 = 142
11 * 13 = 143 5 * 29 = 145 2 * 73 = 146 5 * 31 = 155 2 * 79 = 158
3 * 53 = 159 7 * 23 = 161 2 * 83 = 166 3 * 59 = 177 2 * 89 = 178
3 * 61 = 183 5 * 37 = 185 11 * 17 = 187 2 * 97 = 194 3 * 67 = 201
2 * 101 = 202 7 * 29 = 203 5 * 41 = 205 2 * 103 = 206 11 * 19 = 209
3 * 71 = 213 2 * 107 = 214 5 * 43 = 215 7 * 31 = 217 2 * 109 = 218
3 * 73 = 219 13 * 17 = 221 2 * 113 = 226 5 * 47 = 235 3 * 79 = 237
13 * 19 = 247 3 * 83 = 249 11 * 23 = 253 2 * 127 = 254 7 * 37 = 259
2 * 131 = 262 5 * 53 = 265 3 * 89 = 267 2 * 137 = 274 2 * 139 = 278
7 * 41 = 287 3 * 97 = 291 5 * 59 = 295 2 * 149 = 298 13 * 23 = 299
7 * 43 = 301 2 * 151 = 302 3 * 101 = 303 5 * 61 = 305 3 * 103 = 309
2 * 157 = 314 11 * 29 = 319 3 * 107 = 321 17 * 19 = 323 2 * 163 = 326
3 * 109 = 327 7 * 47 = 329 2 * 167 = 334 5 * 67 = 335 3 * 113 = 339
11 * 31 = 341 7 * 49 = 343 2 * 173 = 346 5 * 71 = 355 2 * 179 = 358
2 * 181 = 362 5 * 73 = 365 7 * 53 = 371 13 * 29 = 377 3 * 127 = 381
2 * 191 = 382 2 * 193 = 386 17 * 23 = 391 3 * 131 = 393 2 * 197 = 394
5 * 79 = 395 2 * 199 = 398 13 * 31 = 403 11 * 37 = 407 3 * 137 = 411
7 * 59 = 413 5 * 83 = 415 3 * 139 = 417 2 * 211 = 422 7 * 61 = 427
19 * 23 = 437 5 * 89 = 445 2 * 223 = 446 3 * 149 = 447 11 * 41 = 451
3 * 151 = 453 2 * 227 = 454 2 * 229 = 458 2 * 233 = 466 7 * 67 = 469
3 * 157 = 471 11 * 43 = 473 2 * 239 = 478 13 * 37 = 481 2 * 241 = 482
5 * 97 = 485 3 * 163 = 489 17 * 29 = 493 7 * 71 = 497
Counts under 500: MPNs = 149 Semi-primes = 153
 
Counts under 5000: MPNs = 1353 Semi-primes = 1365
 
Counts under 50000: MPNs = 12073 Semi-primes = 12110
 
Counts under 500000: MPNs = 108222 Semi-primes = 108326
</pre>
 
=={{header|Phix}}==
4,105

edits