Question: Please write code Program Name: Shivani.java Input File: shivanidat You and Shivani are doing a project for your ancient architeeture class, and you need to
Program Name: Shivani.java Input File: shivanidat You and Shivani are doing a project for your ancient architeeture class, and you need to go buy materials. Your project will be a triangular pyramid made of spheres. The top of the pyramid will be one sphere, and the layer below it will be 3 spheres. The nth layer in the pyramid will have n more spheres than the one above it, so 3+36,6 spheres in the 3Md layer, and so on. You will be given n, the number of layers, and you need to determine how many spheres you will need for the pyramid project. Input: The first line will contain a single integer m thar indicates the number of data sets that follow. Each of the following m lines will contain an integer n, the number of layers in your triangular pyramid. Note: The values for n may be quite large, n may be greater than 2.64 (meaning it is too big for an int or long). Output: Output the number of spheres needed to form the triangular pyramid with n layers, as shown in the sample output. Sample input: 4 6 12 25 53 Sample output: 56 364 2925 26235
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
