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


Please Help Members By Posting Answers For Below Questions

How is javascript different from java?

472


How to get value from radiobuttonlist control?

499


What is push() method in javascript?

494


How to embed javascript in a web page?

500


What are screen objects?

522






Where javascript variables are stored?

465


What is difference between local variable and global?

474


Explain the difference between java and javascript.

507


What is shift() method in javascript?

501


Explain higher-order functions in javascript?

528


How to set a html document's background color?

547


how do you declare variables in javascript?

489


What is string in javascript?

506


What is unobtrusive javascript?

498


What javascript method would convert the string “20” to an integer (on the fly) so “20” + 20 = 40?

527