Page

Program to print the series in java script

<html>
<head><h2><center>program to print the series</h2></center></head>
<body>
<script type="text/javascript">
n=parseInt(prompt("enter the number of rows"," "));
for(i=1;i<=n;i++)
{
document.write("<br>");
for(j=1;j<=n-i;j++)
document.write("&nbsp&nbsp");
for(k=1;k<=i;k++)
document.write(k);
for(l=i-1;l>0;l--)
document.write(l);
}
</script>
</body>
</html>

Program to evaluate series 1+1/2+1/3+1/4+-------+1/N in java script

<html>
<head><h2><center>program to evaluate series 1+1/2+1/3+1/4+-------+1/N</h2></center></head>
<body>
<script type="text/javascript">
n=parseInt(prompt("enter the value for n"," "));
s=0.0;
for(i=1;i<=n;i++)
{
s=s+(1/i);
}
document.write("the sum of series is "+s);
</script>
</body>
</html>

Program to find the reverse of a number in java script

<html>
<head><h2><center>program to find the reverse of a number</h2></center></head>
<body>
<script type="text/javascript">
n=parseInt(prompt("enter the number"," "));
rev=0;
x=n;
while(n>0)
{
m=n%10;
rev=parseInt(rev*10+m);
n=parseInt(n/10);
}
document.write("reverse of a given number "+x+"  is "+rev);
</script>
</body>
</html>

Program to check wheather the given number is armstrong or not in java script

<html>
<head><h2><center>program to check wheather the given number is armstrong or not</h2></center></head>
<body>
<script type="text/javascript">
n=parseInt(prompt("enter the number"," "));
sum=0;
x=n;
while(n>0)
{
m=n%10;
l=m*m*m;
sum=parseInt(sum +l);
n=parseInt(n/10);
}
document.write(sum);
if(sum==x)
document.write("number "+x+"  is armstrong number");
else
document.write("number "+x+"is not an armstrong number");
</script>
</body>
</html>

Program to print the sum of digits of given number in java script

<html>
<head><h2><center>program to print the sum of digits of given number</h2></center></head>
<body>
<script type="text/javascript">
n=parseInt(prompt("enter the number"," "));
sum=0;
x=n;
while(n>0)
{
m=n%10;
n=n/10;
sum=parseInt(sum+m);
}

document.write("the sum of digits of "+"     "+x+"   "+"is   "+"     "+sum);
</script>
</body>
</html>