Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Metallic-ratios/Sidef/metallic-ratios.sidef
Normal file
23
Task/Metallic-ratios/Sidef/metallic-ratios.sidef
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
func seqRatio(f, places = 32) {
|
||||
1..Inf -> reduce {|t,n|
|
||||
var r = (f(n+1)/f(n)).round(-places)
|
||||
return(n, r.as_dec(places + r.abs.int.len)) if (r == t)
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
for k,v in (%w(Platinum Golden Silver Bronze Copper Nickel Aluminum Iron Tin Lead).kv) {
|
||||
next if (k == 0) # undefined ratio
|
||||
say "Lucas sequence U_n(#{k},-1) for #{v} ratio"
|
||||
var f = {|n| lucasu(k, -1, n) }
|
||||
say ("First 15 elements: ", 15.of(f).join(', '))
|
||||
var (n, r) = seqRatio(f)
|
||||
say "Approximated value: #{r} reached after #{n} iterations"
|
||||
say ''
|
||||
}
|
||||
|
||||
with (seqRatio({|n| fib(n) }, 256)) {|n,v|
|
||||
say "Golden ratio to 256 decimal places:"
|
||||
say "Approximated value: #{v}"
|
||||
say "Reached after #{n} iterations"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue