Alex sells pyramid wall art. In the design of his pyramids have each row has one more block than the last which means row 10 has 10 blocks, row 9 will have nine blocks …. Different customers want different size pyramids so Alex wants a simple function that when he enters the number of rows, it will return the number of blocks he needs for the pyramid. Create the function PyramidBlocks(rows) that adds up all the numbers from 1 to rows. For example: if the input is 4 then your program should return 10 because 1 + 2 + 3 + 4 = 10. For the test cases, the parameter rows will be any number from 1 to 1000. Sample Test Cases Input:12 Output:78 Input:140 Output:9870



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *