2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -3,22 +3,22 @@ package main
import "fmt"
func A(k int, x1, x2, x3, x4, x5 func() int) (a int) {
var B func() int
B = func() (b int) {
k--
a = A(k, B, x1, x2, x3, x4)
b = a
return
}
if k <= 0 {
a = x4() + x5()
} else {
B()
}
return
var B func() int
B = func() (b int) {
k--
a = A(k, B, x1, x2, x3, x4)
b = a
return
}
if k <= 0 {
a = x4() + x5()
} else {
_ = B()
}
return
}
func main() {
K := func(x int) func() int { return func() int { return x } }
fmt.Println(A(10, K(1), K(-1), K(-1), K(1), K(0)))
K := func(x int) func() int { return func() int { return x } }
fmt.Println(A(10, K(1), K(-1), K(-1), K(1), K(0)))
}

View file

@ -0,0 +1,34 @@
package main
import "fmt"
func eval(v interface{}) int {
switch v := v.(type) {
case int:
return v
case func() int:
return v()
}
panic("bad type")
return 0
}
func A(k int, x1, x2, x3, x4, x5 interface{}) (a int) {
var B func() int
B = func() (b int) {
k--
a = A(k, B, x1, x2, x3, x4)
b = a
return
}
if k <= 0 {
a = eval(x4) + eval(x5)
} else {
_ = B()
}
return
}
func main() {
fmt.Println(A(10, 1, -1, -1, 1, 0))
}

View file

@ -0,0 +1,39 @@
package main
import (
"fmt"
"math/big"
)
func A(k int) *big.Int {
one := big.NewInt(1)
c0 := big.NewInt(3)
c1 := big.NewInt(2)
c2 := big.NewInt(1)
c3 := big.NewInt(0)
for j := 5; j < k; j++ {
c3.Sub(c3.Add(c3, c0), one)
c0.Add(c0, c1)
c1.Add(c1, c2)
c2.Add(c2, c3)
}
return c0.Add(c0.Sub(c0.Sub(c0, c1), c2), c3)
}
func p(k int) {
fmt.Printf("A(%d) = ", k)
if s := A(k).String(); len(s) < 60 {
fmt.Println(s)
} else {
fmt.Printf("%s...%s (%d digits)\n",
s[:6], s[len(s)-5:], len(s)-1)
}
}
func main() {
p(10)
p(30)
p(500)
p(10000)
p(1e6)
}