how can I populate an array with results from multiple operations like a harmonic sum: Harmonic= 1+1/2+1/3+1/4.......+1/n My incomplete version looks like this:
public static void main(String[] args) {
int x=1, harmonic=0, y=2;
int[] n;
n = new int[];
// for populating the array ?!?!?!
do {n = {x/y}}
y++;
while (y<=500);
//for the sum for loop will do...
for (int z=0; z<=n.length; z++){
harmonic += n[z];
}
System.out.println("Harmonic sum is: " + harmonic);
}