Tuesday, 19 February 2013

Armstrong number


Write a java script for an ARMSTRONG number using WHILE loop

<html>
<head><TITLE></TITLE>
<script language="JavaScript">
var b,z,c=0;
var a=prompt("Enter a number");
z=a;
while(z>0)
{
b=z%10;
c=c+(b*b*b);
z=parseInt(z/10);
}
if(a==c)
alert("given no is amstrong number");
else
alert("given no is not an amstrong number");
</script>
</head>
<body></body>
</html>