suresh34 suresh34
  • 17-07-2018
  • Computers and Technology
contestada

write a programme to find the sum of first three cube number?

help me to know all the syntex of programming

Respuesta :

Ongly
Ongly Ongly
  • 17-07-2018

// Simple Java program to find sum of series

// with cubes of first n natural numbers

import java.util.*;

import java.lang.*;

class GFG {

/* Returns the sum of series */

public static int sumOfSeries(int n)

{

int sum = 0;

for (int x = 1; x <= n; x++)

sum += x * x * x;

return sum;

}

// Driver Function

public static void main(String[] args)

{

int n = 5;

System.out.println(sumOfSeries(n));

}

}

// Code Contributed by Mohit Gupta_OMG <(0_o)>

Answer Link

Otras preguntas

What produces the wavy effect in air over a hot stove
What are the values of x in the equation x(x-6)=4(x+6)
A trailing or climbing plant is also known as a _____?
solve for x simplify the answer. this is extremely hard
1. Which ordered pair is the best estimate of the solution of the system? (Points : 1) A. (2.1, –0.8) B. (2.1, –0.2) C. (2.7, –0.8) D.
Primitive man used butter as what?
Which is the best estimate for the expression? 49% of 15
A patio in the shape of a semicircle has a diameter of 21 ft. What is the approximate area of the patio, rounded to the nearest square foot? Use 3.14 to approxi
In a certain plant species, the allele for wrinkled seeds (W) is dominant to the allele for smooth seeds. What is the phenotype result of a cross between a true
Which of the following if added to this sequence A—G—A—T—G—C—G—A—G—T—T—A—C—G—G might create an insertion mutation? A. a DNA molecule B. a fat molecule C. a suga