Pairs with common factors: Difference between revisions

Added Easylang
(Added Quackery.)
(Added Easylang)
Line 283:
The 1,000,000th term: 196,035,947,609
</pre>
 
=={{header|EasyLang}}==
{{trans|Phix}}
<syntaxhighlight>
func isprim num .
if i < 2
return 0
.
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
func totient n .
tot = n
i = 2
while i * i <= n
if n mod i = 0
repeat
n /= i
until n mod i <> 0
.
tot -= tot / i
.
if i = 2
i = 1
.
i += 2
.
if n > 1
tot -= tot / n
.
return tot
.
write "1-100:"
for n = 1 to 1000
sumPhi += totient n
if isprim n = 1
a = ap
else
a = n * (n - 1) / 2 + 1 - sumPhi
.
if n <= 100
write " " & a
.
ap = a
.
print ""
print "1000: " & a
</syntaxhighlight>
 
=={{header|Factor}}==
2,083

edits