Tutorial Webpage for

Lecture Cloud- and Web-Technologies

Loading...

Login

Please use user and password as given in the lecture! Please copy the editor's content, as it will be lost due to reloading of the page for the purpose of login.

Username:

Password:

Kotlin - Endrecursive Functions

Transform the following recursive function (for computing the fibonacci numbers) into an equivalent endrecursive function and afterwards in an iterative function!

fun fibonacci(n:Int): Int = 
    if(n<=1) n else fibonacci(n-1) + fibonacci(n-2)

Editor

Please use the following editor for your exercise. You can run the content of the editor by clicking on the tab 'Run'...

Output of Editor Content

The result of running the editor content is as follows:

Output of the Solution

The output of the solution is as follows:

Solution

Please have a look at the solution only after you have finished working on your own solution. Otherwise the learn effect is much less.