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

Describe the limitations of using models to represent atoms
Please fill the blanks with the right answers A. Nucleus B. Mitochondria C. Endoplasmic reticulum D. Cell wall E. Cell membrane F. Ribosomes G. Lysosome H.
Describe the wavelength of a longitudinal wave.
Describe the wavelength of a longitudinal wave.
Determine the equation of g(x) that results from translating the function f(x) = (x + 10)2 to the right 12 units.
Please fill the blanks with the right answers A. Nucleus B. Mitochondria C. Endoplasmic reticulum D. Cell wall E. Cell membrane F. Ribosomes G. Lysosome H.
Describe the limitations of using models to represent atoms
Why are different constellations of stars seen during different seasons?
How does an an electron microscope work?
Please fill the blanks with the right answers A. Nucleus B. Mitochondria C. Endoplasmic reticulum D. Cell wall E. Cell membrane F. Ribosomes G. Lysosome H.