Special odd numbers: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{Draft task}} Category:Prime Numbers ;Task: Odd numbers of the form p*q where p and q are distinct primes, where '''p*q < 1000''' <br><br> =={{header|Ring}}== <lang ring...")
 
m (Link to new page)
 
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Task moved to [[Odd squarefree semiprimes]] one.
{{Draft task}}
[[Category:Prime Numbers]]

;Task:
Odd numbers of the form p*q where p and q are distinct primes, where '''p*q < 1000'''
<br><br>
=={{header|Ring}}==
<lang ring>
load "stdlib.ring"

see "working..." + nl
see "Special odd numbers are:" + nl

row = 0
limit1 = 150
Prim = []

for n = 1 to limit1
for m = n+1 to limit1-1
if isprime(n) and isprime(m)
prod = n*m
if prod%2 = 1
add(Prim,prod)
ok
ok
next
next

Prim = sort(Prim)
for n = 1 to len(Prim)
if Prim[n] > 1000
n = n - 1
exit
ok
see "" + Prim[n] + " "
if n%10 = 0
see nl
ok
next

see nl + "Found " + n + " Special odd numbers." + nl
see "done..." + nl
</lang>
{{out}}
<pre>
working...
Special odd numbers are:
15 21 33 35 39 51 55 57 65 69
77 85 87 91 93 95 111 115 119 123
129 133 141 143 145 155 159 161 177 183
185 187 201 203 205 209 213 215 217 219
221 235 237 247 249 253 259 265 267 287
291 295 299 301 303 305 309 319 321 323
327 329 335 339 341 355 365 371 377 381
391 393 395 403 407 411 413 415 417 427
437 445 447 451 469 473 481 485 493 497
505 511 515 517 527 533 535 545 551 553
559 565 581 583 589 611 623 629 635 649
655 667 671 679 685 689 695 697 703 707
713 721 731 737 745 749 763 767 779 781
791 793 799 803 817 851 869 871 889 893
899 901 913 917 923 943 949 959 973 979
989
Found 151 Special odd numbers.
done...
</pre>

Latest revision as of 14:06, 3 April 2021

Task moved to Odd squarefree semiprimes one.