### Program to print prime number pyramid

I think you've already figured it out by looking at the above pattern that the numbers are all prime numbers. I've written the program to print this pattern. It takes number of lines \((n)\) as input and prints exactly \(n(n+1)/2\) prime numbers. For example, if \(n=4\) then we have \(4(4+1)/2 = 10\) prime numbers in the pattern. Let's be a little elaborative, each line in the pattern has prime numbers exactly equal to the line number. For example, line 4 will have 4 prime numbers, similarly, line 7 will have 7 prime numbers.

\[\therefore 1 + 2 + 3 + 4 +...+(n-1)+ n\\

= n(n+1)/2\\

or, \sum_{i=1}^{n} i = n(n+1)/2\]

Below is the code:

If you've found any errors or want to give a feedback then comment below.

References: http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/runsums/triNbProof.html

## Comments

## Post a Comment