write a program to generte a harmonic series
1+1/2+1/3+1/4+1/5 upto 15 terms.
Answer Posted / upendar
<html>
<head>
<script type="text/javascript">
function hormonicSeries() {
for(var i=1;i<=15;i++) {
if(i == 1) {
var addSeries = 1/i;
} else {
for(var j=2; j<=15;j++) {
if(i == j) {
addSeries = addSeries +"+1/"+i ;
}
}
}
}
var series = addSeries;
document.write(series);
}
</script>
</head>
<body onload="hormonicSeries();">
</body>
</html>
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
Should you use var or let?
What is the difference between HTMLCollection and NodeList?
What are trailing whitespace?
Create an array in javascript with a list of 4 colors, assign that array to the variable, ‘colors’.
What is the purpose of 'this' operator in JavaScript?
How do you define a class and its constructor?
How do you check if a variable is an object
What is variable typing in javascript?
What is push() method in javascript?
How do we add javascript onto a web page?
How do I open a .js file?
What does it mean in javascript?
What is eager initialization in java?
Between JavaScript and an ASP script, which is faster?
how do you declare variables in javascript?