Created
August 1, 2019 03:41
-
-
Save DPS0340/58b62cf6e2170debd1ec29422aa4336d to your computer and use it in GitHub Desktop.
tailrec times table scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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