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

whats the lcm of 30, 45, 10
True or false: We know the meaning of all pictographs and petroglyphs
How many pictures would you draw if 12 students chose game shows as their favorite kind of TV show?
Help please with these questions.
What does the word innocuous mean? A. terrrible B.fantastic C.harmless,but bland D.abundant
each blank should be filled with a single whole number greater than 1. factor: 900 - 1 = ( )( )
how many pounds of honey will 1 hive produce
1) solve for h. 6.51 - 9.32 h = 1.02
which sentence best describes the dramatic situation of whitman's "song of the open road"? the speaker has reached a fork in the road and must choose which way
The means is defined as the A)number that show up most often in a data set. B) middle of the data set C) average of a data set D)range of the data set