Skip to content

Instantly share code, notes, and snippets.

@DPS0340
Created August 1, 2019 03:41
Show Gist options
  • Select an option

  • Save DPS0340/58b62cf6e2170debd1ec29422aa4336d to your computer and use it in GitHub Desktop.

Select an option

Save DPS0340/58b62cf6e2170debd1ec29422aa4336d to your computer and use it in GitHub Desktop.
tailrec times table scala
import scala.annotation.tailrec
def gugu(max: Int): Unit = {
@tailrec
def go(i:Int, j:Int): Unit = {
if(i > max) return
else if(j > max) return go(i+1, 1)
else {
println("%d * %d = %d".format(i, j, i*j))
go(i, j+1)
}
}
go(1, 1)
}
gugu(9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment