Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tail recursion #48

Open
ldemailly opened this issue Jul 19, 2024 · 0 comments
Open

tail recursion #48

ldemailly opened this issue Jul 19, 2024 · 0 comments

Comments

@ldemailly
Copy link
Member

would be neat to get

// Γ(x + 1/2) ~ Γ(x)x^(1/2) = (x-1)!√x
// Γ(x + 1/2) = (2x - 1)!! * 2^-x * √π
f=func(i,n, prod) {
    //log(i, prod)
	if (i==n+1) {
        return 1./(prod*prod*n)
    }
    f(i+1, n, prod * ( 1 - 1./(2*i)))
}
n=200000
f(1,n,1)

to work for larger Ns withou

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0x14020408380 stack=[0x14020408000, 0x14040408000]
fatal error: stack overflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant