Armstrong Number in javascript

Keshav Gautam
Sep 9, 2021

--

function checkArmstrongNumber(i){

let sum=0,r=0,n=i;

while(i>0){
r=i%10;
sum=sum+(r*r*r);

i=parseInt(i/10)
console.log(sum,r,i)
}
console.log(n,”===”,sum)
if(n===sum){
return “armstrong number “
}else{
return “not armstrong number “
}
}

// console.log(checkArmstrongNumber(407))

console.log(checkArmstrongNumber(153))

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Keshav Gautam
Keshav Gautam

No responses yet

Write a response