-
Notifications
You must be signed in to change notification settings - Fork 0
/
tower_of_distinct_powers.sf
53 lines (42 loc) · 1.2 KB
/
tower_of_distinct_powers.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
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/ruby
# Daniel "Trizen" Șuteu
# Date: 05 June 2020
# https://github.com/trizen
# Find a solution to a^b^c^...^(z^z) = n, for a tower of k distinct powers.
func tower_of_powers(n, k) {
gather {
k.times {
take(n = n.lgrt)
}
}
}
var arr = tower_of_powers(2, 10)
with ('a') {|l|
arr.each {|x|
say "#{l++} = #{x}"
}
say "\nResult for a^b^c^...^z:"
say arr.flip.reduce{|a,b|
b**a
}
arr << arr.last
say "\nResult for a^b^c^...^(z^z):"
say arr.flip.reduce{|a,b|
b**a
}
}
__END__
a = 1.55961046946236934997038876876500299328488351184
b = 1.37997039661105766557865852046718024244983839926
c = 1.28486974908322111138116130550302803396637862332
d = 1.22670717265797917836276308964722787277231977304
e = 1.18772296630757250640873514031261013753776638981
f = 1.1598874880354098360292139394176647261367943972
g = 1.13907200407942084565168221813587429120796585878
h = 1.1229478230276636302739154417957596485177010612
i = 1.1101064783478007292988613612539909225461593927
j = 1.09964821208918239074785053448745934624006797166
Result for a^b^c^...^z:
1.99999996313334546345876725053319567243649389716
Result for a^b^c^...^(z^z):
2