Skip to content

Instantly share code, notes, and snippets.

@xaviervia
Created November 4, 2017 16:54
Show Gist options
  • Save xaviervia/9fe90fb9a9bc1bb6a788aa802cf7d0bf to your computer and use it in GitHub Desktop.
Save xaviervia/9fe90fb9a9bc1bb6a788aa802cf7d0bf to your computer and use it in GitHub Desktop.
Riemann 𝜻 function in Idris, quick and dirty implementation for the rationals that prints information on each iteration
riemannZeta : (s : Double) -> IO Double
riemannZeta s = riemannZetaStep s 1.0 0.0
where riemannZetaStep : (s : Double) -> (n : Double) -> (p : Double) -> IO Double
riemannZetaStep s n p =
do let currentPower = pow n s
let currentFraction = 1.0 / currentPower
let currentValue = currentFraction + p
putStrLn ("s " ++ show s)
putStrLn ("n " ++ show n)
putStrLn ("power " ++ show currentPower)
putStrLn ("fraction " ++ show currentFraction)
putStrLn ("value " ++ show currentValue)
putStrLn "---"
riemannZetaStep s (n + 1.0) currentValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment