Ruth-Aaron numbers: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added Easylang)
 
(One intermediate revision by one other user not shown)
Line 430:
Elapsed Time: 5.991 Sec.
 
</pre>
 
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight>
func divsum n alldiv .
f = 2
repeat
q = n / f
if n mod f = 0
if alldiv = 1
s1 += f
else
if f <> f0
s1 += f
f0 = f
.
.
n = q
else
f += 1
.
until f > n
.
return s1
.
proc ruth_aaron alldiv . .
n = 2
repeat
s = divsum n alldiv
if s = s0
write n - 1 & " "
c += 1
.
s0 = s
n += 1
until c >= 30
.
.
print "first 30 ruth-aaron numbers (factors):"
ruth_aaron 1
print ""
print ""
print "first 30 ruth-aaron numbers (divisors):"
ruth_aaron 0
</syntaxhighlight>
{{out}}
<pre>
first 30 ruth-aaron numbers (factors):
5 8 15 77 125 714 948 1330 1520 1862 2491 3248 4185 4191 5405 5560 5959 6867 8280 8463 10647 12351 14587 16932 17080 18490 20450 24895 26642 26649
 
first 30 ruth-aaron numbers (divisors):
5 24 49 77 104 153 369 492 714 1682 2107 2299 2600 2783 5405 6556 6811 8855 9800 12726 13775 18655 21183 24024 24432 24880 25839 26642 35456 40081
</pre>
 
Line 941 ⟶ 994:
 
Ruth Aaron factor triple starts at: 417162
</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
{{trans|Julia}}
<syntaxhighlight lang="Mathematica">
SumPrimeDivisors[n_] := Total[First /@ FactorInteger[n]]
RuthAaron[n_] := SumPrimeDivisors[n] == SumPrimeDivisors[n + 1]
 
SumPrimeFactors[n_] :=
Total[First[#] * Last[#] & /@ FactorInteger[n]]
RuthAaronFactors[n_] :=
SumPrimeFactors[n] == SumPrimeFactors[n + 1]
 
RuthAaronSeq := Select[Range[100000], RuthAaron]
RuthAaronFactorSeq := Select[Range[100000], RuthAaronFactors]
 
Print["30 Ruth Aaron numbers:"]
Print[Take[RuthAaronSeq, 30]]
 
Print["\n30 Ruth Aaron factor numbers:"]
Print[Take[RuthAaronFactorSeq, 30]]
</syntaxhighlight>
{{out}}
<pre>
30 Ruth Aaron numbers:
{5, 24, 49, 77, 104, 153, 369, 492, 714, 1682, 2107, 2299, 2600, 2783, 5405, 6556, 6811, 8855, 9800, 12726, 13775, 18655, 21183, 24024, 24432, 24880, 25839, 26642, 35456, 40081}
 
30 Ruth Aaron factor numbers:
{5, 8, 15, 77, 125, 714, 948, 1330, 1520, 1862, 2491, 3248, 4185, 4191, 5405, 5560, 5959, 6867, 8280, 8463, 10647, 12351, 14587, 16932, 17080, 18490, 20450, 24895, 26642, 26649}
 
</pre>
 
2,083

edits