Multiplicatively perfect numbers: Difference between revisions

→‎{{header|Wren}}: Changed to include '1' as an MPN.
(Added a note to make the inclusion of '1' as a MPN optional.)
(→‎{{header|Wren}}: Changed to include '1' as an MPN.)
Line 471:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
This includes '1' as an MPN.
<syntaxhighlight lang="ecmascript">import "./math" for Int, Nums
import "./fmt" for Fmt
Line 479 ⟶ 480:
System.print("Multiplicatively perfect numbers under %(limit):")
while (true) {
var pd = (i != 1) ? Int.properDivisors(i).skip(1) : [1, 1]
if (pd.count > 1 && Nums.prod(pd) == i) {
count = count + 1
Line 485 ⟶ 486:
var pds = pd.map { |d| Fmt.d(3, d) }.join(" x ")
Fmt.write("$3d = $s ", i, pds)
if (count % 45 == 0) System.print()
}
}
if (i == 499) System.print("\n")
if (i >= limit - 1) {
var squares = Int.primeSieve((limit - 1).sqrt.floor).count
var cubes = Int.primeSieve((limit - 1).cbrt.floor).count
var count2 = count + squares - cubes - 1
Fmt.print("Counts under $,7d: MPNs = $,7d Semi-primes = $,7d", limit, count, count2)
if (limit == 500000) return
Line 503 ⟶ 504:
<pre>
Multiplicatively perfect numbers under 500:
1 = 1 x 1 6 = 2 x 3 8 = 2 x 4 10 = 2 x 5 14 = 2 x 7
15 = 3 x 5 21 = 3 x 7 22 = 2 x 11 26 = 2 x 13 27 = 3 x 9
2733 = 3 x 11 9 34 33 = 2 x 17 35 = 35 x 11 7 34 38 = 2 x 1719 3539 = 53 x 713
3846 = 2 x 1923 3951 = 3 x 1317 4655 = 25 x 2311 5157 = 3 x 1719 58 = 2 x 29
5562 = 2 x 31 65 = 5 x 1113 5769 = 3 x 1923 5874 = 2 x 2937 6277 = 27 x 3111
6582 = 52 x 1341 6985 = 35 x 2317 7486 = 2 x 3743 7787 = 3 x 29 91 = 7 x 1113
8293 = 3 x 31 94 = 2 x 4147 8595 = 5 x 1719 86106 = 2 x 43 53 87111 = 3 x 2937
91115 = 75 x 1323 93118 = 32 x 3159 119 94 = 7 x 17 122 = 2 x 4761 95123 = 53 x 1941
106125 = 25 x 5325 111129 = 3 x 3743 115133 = 57 x 2319 118134 = 2 x 5967 141 = 3 x 47
119142 = 72 x 1771 122143 = 11 2x 13 145 = 5 x 6129 123146 = 32 x 4173 125155 = 5 x 2531
129158 = 2 x 79 159 = 3 x 4353 133161 = 7 x 1923 134166 = 2 x 6783 141177 = 3 x 4759
142178 = 2 x 7189 143183 = 11 3 x 1361 145185 = 5 x 2937 187 = 11 x 17 146194 = 2 x 7397
155201 = 53 x 3167 158202 = 2 x 101 79 159203 = 37 x 5329 161205 = 75 x 2341 206 = 2 x 103
166209 = 211 x 8319 177213 = 3 x 5971 178214 = 2 x 107 89 215 183 = 5 x 43 217 = 37 x 6131
185218 = 52 x 109 37 219 187 = 3 x 73 221 = 1113 x 17 194226 = 2 x 113 97 201235 = 35 x 6747
202237 = 23 x 101 79 203 247 = 713 x 2919 205249 = 53 x 83 253 = 11 x 4123 206254 = 2 x 103127
209259 = 11 7 x 1937 213262 = 32 x 131 71 214265 = 25 x 107 53 215 267 = 53 x 4389 274 = 2 x 137
217278 = 72 x 139 31 218287 = 27 x 109 41 219 291 = 3 x 7397 221295 = 13 5 x 1759 298 = 2 x 149
226299 = 213 x 113 23 235 301 = 57 x 4743 237302 = 32 x 151 79 303 247 = 3 x 101 305 = 13 5 x 1961
249309 = 3 x 103 83 314 253 = 2 x 157 319 = 11 x 2329 254321 = 23 x 127107 259323 = 717 x 3719
262326 = 2 x 131163 265327 = 53 x 109 53 267329 = 37 x 8947 274334 = 2 x 137167 335 = 5 x 67
278339 = 23 x 139113 287341 = 11 x 31 343 = 7 x 4149 291346 = 32 x 97173 295355 = 5 x 5971
298358 = 2 x 149179 299362 = 13 2 x 181 23 365 301 = 5 x 73 371 = 7 x 4353 302377 = 13 2x x 15129
303381 = 3 x 101127 305382 = 52 x 191 61 309386 = 32 x 103193 314391 = 17 2x 23 393 = 3 x 157131
319394 = 11 2 x 197 29 395 321 = 5 x 79 398 = 32 x 107199 323403 = 1713 x 1931 326407 = 211 x 163 37
327411 = 3 x 109137 329413 = 7 x 4759 334415 = 25 x 167 83 335 417 = 53 x 139 422 = 2 x 67211
339427 = 37 x 113 61 341 437 = 1119 x 3123 343445 = 75 x 4989 346446 = 2 x 173223 447 = 3 x 149
355451 = 511 x 7141 358453 = 23 x 179151 362454 = 2 x 181227 365458 = 52 x 229 466 = 2 x 73233
371469 = 7 x 5367 377471 = 13 3 x 157 29 381473 = 311 x 127 43 382 478 = 2 x 191239 481 = 13 x 37
386482 = 2 x 193241 391485 = 17 5 x 2397 393489 = 3 x 131163 394493 = 17 2x 29 497 = 7 x 197 71
395 = 5 x 79 398 = 2 x 199 403 = 13 x 31 407 = 11 x 37
411 = 3 x 137 413 = 7 x 59 415 = 5 x 83 417 = 3 x 139
422 = 2 x 211 427 = 7 x 61 437 = 19 x 23 445 = 5 x 89
446 = 2 x 223 447 = 3 x 149 451 = 11 x 41 453 = 3 x 151
454 = 2 x 227 458 = 2 x 229 466 = 2 x 233 469 = 7 x 67
471 = 3 x 157 473 = 11 x 43 478 = 2 x 239 481 = 13 x 37
482 = 2 x 241 485 = 5 x 97 489 = 3 x 163 493 = 17 x 29
497 = 7 x 71
 
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