I had been trying to limit for some c++ programs, the bigest whole number they can handle is
lim = 18446744073709551615
and the different functions are:
tfn[k_] := Total[Table[n!, {n, k}]]
or
spd2[n_] := Total[Table[2^i, {i, n}]]
the only way I found to know the limit k that do not overflow is
klimtfn = For[i = 1, 1 < 100, i++, If[tfn[i] > lim, Break[]]]; i - 1
or
klimspd2 = For[i = 1, 1 < 100, i++, If[spd2[i] > lim, Break[]]]; i - 1
for both cases I found correct answers, my concern is I have used for
and this is like unfair, surely I must learn something better otherwise.
Thanks for advice.
Developer`$MaxMachineInteger
return for you? $\endgroup$spd2
is a finite geometric series, yes? Equate it toDeveloper`$MaxMachineInteger
and solve for the largest possible index. $\endgroup$