# Print Pascal's Triangle [duplicate]

## Overview

Pascal's triangle is the series of rows of numbers, starting with 1, where each cell is formed by summing the two above it. Here's an example.

## Challenge and Scoring

The challenge is simple: given a number, print that many rows of Pascal's Triangle in as few characters as possible. Lowest character count wins. Each row should be separated by newlines, and each number by spaces.

Again, this is code golf: lowest character count wins.

### Example

Given 4, the program should print

1
1 1
1 2 1
1 3 3 1


## Sample solution

<?php
$currentRow = [1];$num = (int)file_get_contents('php://input');
function add($a,$b){
return $a+$b;
}
while($num >0){ echo implode(' ',$currentRow) . "\n";
$currentRow = array_map( 'add', array_merge([0],$currentRow),
array_merge($currentRow, [0]) );$num--;
}

• Also, there is currently no winning criterion. Is this code-golf? (Not that it matters, seeing as how this is a dupe) – Conor O'Brien Feb 13 '18 at 4:26
• Yes, it is a duplicate. I don't mind taking it down if that's a problem! I did mark in the problem that lowest character count wins. – JJ Brown Feb 13 '18 at 4:29
• Ah, sure enough. Usually we have the code-golf tag on code golf challenges. Welcome to PPCG, and good luck on your next challenge! May I suggest the sandbox? You can iron out any potential problems there :) – Conor O'Brien Feb 13 '18 at 4:32
• Welcome to PPCG! I'm sorry that your first challenge was a dupe, but thanks for taking it well. It was well-written too. I hope you stick around! – Rɪᴋᴇʀ Feb 13 '18 at 4:50
• I also suggest using the sandbox. Besides, 1. We scores by byte count (see Sclipting esoteric programming language for more details), and 2. We really like flexible I/O format. There is no reason to override that. – user202729 Feb 13 '18 at 10:11