Harmonic series: Difference between revisions

Add bruijn
(Added Easylang)
(Add bruijn)
 
Line 432:
next i
end</syntaxhighlight>
 
=={{header|Bruijn}}==
<syntaxhighlight lang="bruijn">
:import std/List .
:import std/Combinator .
:import std/Math/Rational Q
:import std/Number N
 
# fun Church iteration hack
harmonic [0 &[[(Q.add 1 op) : N.++0]] start [[1]]] ⧗ Unary → Rational
op (+1) : N.--0
start (+0.0f) : (+1)
 
custom-gt? &[[[N.gt? 2 (N.mul 0 N.++1)]]] ⧗ Rational → Νumber → Boolean
 
main [φ cons first-20 first-10-above (harmonic <$> (iterate [[[1 (2 1 0)]]] (+0u)))]
first-20 take (+20)
first-10-above [take (+10) first-above]
first-above [find-index [custom-gt? 0 1] 1] <$> (iterate N.inc (+0))
</syntaxhighlight>
 
Takes a *long* time, but will return the correct result.
 
=={{header|C#}}==
55

edits