Tagged Questions
1
vote
2answers
40 views
Recursively print in scala
I have just picked up Scala like 2 hours ago, and I am thinking of printing a series like 1 to 10 but in a recursive fashion. I do not understand what is wrong with this:
def printSeries(x:Int):Int = ...
2
votes
1answer
152 views
Scala: tail-recursive factorial
Is there anything what could be improved on this code?
def factorial(n: Int, offset: Int = 1): Int = {
if(n == 0) offset else factorial(n - 1, (offset * n))
}
The idea is to have tail-recursive ...
2
votes
2answers
471 views
Code review of Pouring water from code chef using Scala
I had posted this question on Stackoverflow and it seems like code review might be a better venue for my query. My question is as follows:
I am trying to solve the pouring water problem from codechef ...