Skip to content

Commit 0731cc2

Browse files
committed
[Shreyash]: Added code to print harmonic number
1 parent 7290791 commit 0731cc2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)