-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
43 lines (30 loc) · 861 Bytes
/
prog.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/ruby
# 3-powerful numbers that can be written as the sum of two coprime 3-powerful numbers.
# https://oeis.org/A297867
# Known terms:
# 776151559, 3518958160000, 11205183603973252067
var upto = 3518958160000
say "Count: #{upto.powerful_count(3)}"
var table = Hash()
var lookup = Set()
for k in (upto.powerful(3)) {
table{k.rad} := [] << k
lookup << k
}
var keys = table.keys.map{.to_i}
for i in (^keys.len) {
var x = keys[i]
for j in (i+1 .. keys.end) {
var y = keys[j]
x.is_coprime(y) || next
for a in (table{x}), b in (table{y}) {
if (lookup.has(a+b)) {
say "#{a+b} = #{a} + #{b}"
}
}
}
}
__END__
776151559 = 756249048 + 19902511
3518958160000 = 1392672604221 + 2126285555779
11205183603973252067 = 5317378991792784000 + 5887804612180468067