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
What does polyfill mean?
What is a global variable in programming?
How to select an element by id and swapping an image?
What is a name function in javascript?
TypeError: document.getelementbyid(...) is null?
What are the requirements of web application using javascript?
List different ways of empty an array in javascript?
Write about the errors shown in javascript?
Explain escape() in javascript?
Which companies are using node js?
What is escape() function?
What is the use of anonymous function in javascript?
How to comment javascript code?
What are decodeuri() and encodeuri() functions in javascript?
What is an object in javascript, give an example?