We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7290791 commit 0731cc2Copy full SHA for 0731cc2
Repetition Problems/For Loop/HarmonicNumber.js
@@ -0,0 +1,13 @@
1
+/*
2
+ Write program that takes command-line argument n and prints the nth harmonic number
3
+*/
4
+
5
+const prompt = require("prompt-sync")();
6
+console.log();
7
+let n = parseInt(prompt(" Enter term : "))
8
+process.stdout.write(n + "th Harmonic Number : ");
9
+for (i = 1; i < n; i++) {
10
+ process.stdout.write(" 1/" + i + " +");
11
+}
12
+process.stdout.write(" 1/" + n);
13
+console.log("\n");
0 commit comments