Find limit of recursion: Difference between revisions

Line 332:
208923
Segmentation fault (core dumped)</lang>
 
 
=={{header|F_Sharp|F#}}==
A tail-recursive function will run indefinitely without problems (the integer will overflow, though).
 
<lang fsharp>let rec recurse n =
recurse (n+1)
 
recurse 0</lang>
The non-tail recursive function of the following example crashed with a <code>StackOverflowException</code> after 39958 recursive calls:
 
<lang fsharp>let rec recurse n =
printfn "%d" n
1 + recurse (n+1)
 
recurse 0 |> ignore</lang>
 
== Icon and Unicon ==
Anonymous user