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
How is javascript different from java?
How to get value from radiobuttonlist control?
What is push() method in javascript?
How to embed javascript in a web page?
What are screen objects?
Where javascript variables are stored?
What is difference between local variable and global?
Explain the difference between java and javascript.
What is shift() method in javascript?
Explain higher-order functions in javascript?
How to set a html document's background color?
how do you declare variables in javascript?
What is string in javascript?
What is unobtrusive javascript?
What javascript method would convert the string “20” to an integer (on the fly) so “20” + 20 = 40?