You are viewing a single comment's thread. Return to all comments →
object Solution { def nthRow(n: Int): List[Int] = { val row = List(1); (0 until n).foldLeft[List[Int]](row)((acc, r) => acc.head*(n-r)/(r+1)::acc); } def main(args: Array[String]) { (0 until scala.io.StdIn.readInt()).foreach( i => { nthRow(i).foreach(x => print(x + " ")); println(); } ); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Pascal's Triangle
You are viewing a single comment's thread. Return to all comments →