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 inferences can we make for the characters in the book and then there were none
What is the ratio of the geometric sequence 8,56,392,2744
help me pleaseeeeeeeeeeeeeeeeeee
The variable y varies inversely with x and y=8 when x=4. What is y when x=2?
Write an expression for the number of yards in f feet.
Which of the following stage directions from part one of Trifles is designed to express emotion? MRS. PETERS (after taking a step forward). SHERIFF (looking abo
How to find the y-intercept and graph the equation y=4x + 3
How does the government attempt to encourage positive externalities and limit negative externalities?
Can you tell from the coefficient of restitution whether a collision has added kinetic energy to a system, taken some away, or left the system's kinetic energy
Which two teams played in the the very first Super Bow? and who hates school?