remove _ in names
This commit is contained in:
parent
829db87c40
commit
3af7344581
1270 changed files with 0 additions and 18916 deletions
|
|
@ -1,20 +0,0 @@
|
|||
# Calculate Pi using the Arithmetic Geometric Mean of 1 and 1/sqrt(2)
|
||||
#
|
||||
#
|
||||
# Nigel_Galloway
|
||||
# March 8th., 2012.
|
||||
#
|
||||
require 'flt'
|
||||
Flt::BinNum.Context.precision = 8192
|
||||
a = n = 1
|
||||
g = 1 / Flt::BinNum(2).sqrt
|
||||
z = 0.25
|
||||
(0..17).each{
|
||||
x = [(a + g) * 0.5, (a * g).sqrt]
|
||||
var = x[0] - a
|
||||
z -= var * var * n
|
||||
n += n
|
||||
a = x[0]
|
||||
g = x[1]
|
||||
}
|
||||
puts a * a / z
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package require Tcl 8.6
|
||||
|
||||
# http://www.cut-the-knot.org/Curriculum/Algorithms/SpigotForPi.shtml
|
||||
# http://www.mathpropress.com/stan/bibliography/spigot.pdf
|
||||
proc piDigitsBySpigot n {
|
||||
yield [info coroutine]
|
||||
set A [lrepeat [expr {int(floor(10*$n/3.)+1)}] 2]
|
||||
set Alen [llength $A]
|
||||
set predigits {}
|
||||
while 1 {
|
||||
set carry 0
|
||||
for {set i $Alen} {[incr i -1] > 0} {} {
|
||||
lset A $i [expr {
|
||||
[set val [expr {[lindex $A $i] * 10 + $carry}]]
|
||||
% [set modulo [expr {2*$i + 1}]]
|
||||
}]
|
||||
set carry [expr {$val / $modulo * $i}]
|
||||
}
|
||||
lset A 0 [expr {[set val [expr {[lindex $A 0]*10 + $carry}]] % 10}]
|
||||
set predigit [expr {$val / 10}]
|
||||
if {$predigit < 9} {
|
||||
foreach p $predigits {yield $p}
|
||||
set predigits [list $predigit]
|
||||
} elseif {$predigit == 9} {
|
||||
lappend predigits $predigit
|
||||
} else {
|
||||
foreach p $predigits {yield [incr p]}
|
||||
set predigits [list 0]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue