Code:
<!DOCTYPE html>
<html>
<body>
<center>
<h2>Strange Numbers in your Range</h2>
<p id="demo"></p>
<script>
var num,sum,temp;
var text=" ";
var i,x;
i=prompt("Enter the lower limit");
x=prompt("Enter the upper limit");
for (i; i < x; i++)
{
sum=0;
num=i;
while(num > 0)
{
temp=num%10;
sum=sum+(temp*temp*temp);
num=parseInt(num/10);
}
if(i==sum)
{
text=text + "<br/> " + i;
}
}
document.getElementById("demo").innerHTML=text;
</script>
</center>
</body>
</html>
No comments:
Post a Comment