2
高調波のような複数の演算の結果を配列に取り込むにはどうすればいいですか:高調波= 1 + 1/2 + 1/3 + 1/4 ....... + 1/nの 私の不完全なバージョンは次のようになります。複数の結果をJavaの配列に保存
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);
}
まだl基本的なものを稼いでいるので、私は配列でそれをしようとしていたのです。私はあなたの解決策を勉強します。ありがとう ! – dragos