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
Can I learn javascript without html?
To set all checkboxes to true using javascript?
What are decodeuri() and encodeuri() functions in javascript?
What are the application of javascript?
Which symbol is used for comments in Javascript?
What is the difference between HTMLCollection and NodeList?
What Does JavaScript Void(0) Mean?
How to get complete current page url with javascript?
What are the difference between javascript and jquery?
Can we create session in javascript?
How is it possible to get the total number of arguments that are passed to a function?
Explain why asynchronous code is important in javascript?
Can you assign an anonymous function to a variable?
How to define a named function in JavScript?
What is output of “20” + 20 + 20 and “20” + ( 20 + 20)? In javascript?