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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Recursion
  4. Pascal's Triangle

Pascal's Triangle

Problem
Submissions
Leaderboard
Discussions

For a given integer , print the first rows of Pascal's Triangle. Print each row with each value separated by a single space. The value at the row and column of the triangle is equal to where indexing starts from . These values are the binomial coefficients.

The Pascal Triangle

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
....

Input Format

A single line of input, integer .

Constraints

Output Format

Output the first rows of Pascal's triangle.

Sample Input

4  

Sample Output

1  
1 1  
1 2 1  
1 3 3 1   

Author

PRASHANTB1984

Difficulty

Easy

Max Score

10

Submitted By

8134

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy