We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. Practice
  2. Functional Programming
  3. Recursion
  4. Pascal's Triangle
  5. Discussions

Pascal's Triangle

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • ankitvij23 3 years ago+ 0 comments

    Easiest SCALA code

    def main(args: Array[String]) {
            val digit = io.Source.stdin.getLines.take(1).map(_.trim.toInt).next()
            def factorial(num: Int) = (1 to num).product
            (0 until digit).foreach(n =>{
                (0 to n).foreach(r => {
                    print(factorial(n)/(factorial(r) * factorial(n-r)) + " ")
                })
                println()
            } )
        }
    
    2|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature