Computer Science, asked by mohansiddharth, 1 year ago

Identify the logic behind the series

6 28 66 120 190 276....

The numbers in the series should be used to create a Pyramid. The base of the Pyramid will be the widest and will start converging towards the top where there will only be one element. Each successive layer will have one number less than that on the layer below it. The width of the Pyramid is specified by an input parameter N. In other words there will be N numbers on the bottom layer of the pyramid


The Pyramid construction rules are as follows
First number in the series should be at the top of the Pyramid
Last N number of the series should be on the bottom-most layer of the Pyramid, with Nth number being the right-most number of this layer.
Numbers less than 5-digits must be padded with zeroes to maintain the sanctity of a Pyramid when printed. Have a look at the examples below to get a pictorial understanding of what this rule actually means.


QGP: As you see this is an AP with a=22, d=16
QGP: The original series in question is the difference series
QGP: Now, there are N numbers on the base line
QGP: So, there will be a total of N! numbers involved in the pyramid
QGP: First we can calculate them, and store them in an Array
QGP: Next, we see how many digits are there in the largest number. So, now we need all the numbers to have same number of digits as the largest number.
QGP: So, we need to put trailing zeros on smaller numbers. Then it's just a print statement with loops.
QGP: @Mohansiddharth, can we write the program in JAVA?
QGP: One correction: there will be a total of N(N-1)/2 numbers, and not N! Numbers
QGP: Sorry, correction again, total will be N(N+1)/2

Answers

Answered by zairahNatasha
0
6*1=6
6*4+4=28
6*10+6=66
6*17+8=120
6*30+10=190
6*44+12=276....
Similar questions