public class Dummy {
public static void main(String[] args) {
double min = 0.0;
double max = 3.0;
double d = 0.5;
for (double n = min; n <= max; n+=d) {
double result = (Math.pow(n*(n/1), 2)) / 4; // {N(N/1)^2}/4
System.out.print(result + ", ");
}
}
}
The output:
result : 0.0, 0.015625, 0.25, 1.265625, 4.0, 9.765625, 20.25.
You can change the min
/max
values to change the range you want.
as you can see you don’t need any data structure(array) for this problem unless you want to save the result for another use.
0
solved How to write a program in java where summation of the given formula will be printed?