I'm trying to code a function that calculates the N'th value of the positive Bernouille numbers. I want to do it with this recursive formula:
What I've tried so far:
function Get_B(N : in Integer) return Float is
X,Bn,Bk:Float;
begin
if N = 0 then
return 1.0;
else
Bn:=0.0;
for K in 0..(N-1) loop
Bk:=Get_B(K);
X:=1.0-Float(F(N))/(Float(F(K))*Float(F(N-K))) *
Bk/(Float(N)-Float(K)+1.0);
Bn:=Bn+X;
end loop;
return Bn;
end if;
end Get_B;
where F is a factorial function (that is, F(N) means N!). I think there's something wrong with the loop, but I don't know what it is.
I can't post images but here's a link to the equation (the bottom one): https://wikimedia.org/api/rest_v1/media/math/render/svg/2571d0a7024741c0a0ad0eb32cc9333f6024c528