Page

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>

No comments:

Post a Comment