KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I wrote a small piece of code that I believe should have succeeded if tail recursion was optimized, however it blew up the stack. Should I conclude PHP does not optimize tail recursion? function sumrand($n,$sum) { if ($n== 0) { return $sum; } else { return (sumrand($n-1,$sum+rand(0,1))); } } echo sumrand(500000,0)."\n";
Tags (comma-separated)
Save Edits
Cancel