This Ruby example will check given number is Armstrong or not puts "Enter the number" temp=num while num!=0 #implementation of while loop if(temp==sum) Output Enter the number
num=gets.chomp.to_i
sum = 0
rem=num%10
num=num/10
sum=sum+rem*rem*rem
end
puts "The #{temp} is Armstrong"
else
puts "The #{temp} is not Armstrong"
end
153
The 153 is Armstrong
How to Get Input with Gets in Ruby
Ruby program to add two integer numbers
What are some of your favorite gems? What are their alternatives?
how to create an array with Array.[](*args) in Ruby ?
How to get index of array element in Ruby
Ruby program to check whether the given number is Armstrong
Ruby program to generate random numbers
How to add/remove elements to Array in Ruby?
Ruby program to print Fibonacci series
Ruby program to check whether the given number is palindrome
Program to Print Triangle of Numbers in Ruby
Ruby program to reverse a string
Ruby program to print an array
How to Sort Array in Ruby?
How to Replace array elements in Ruby?
How to create two dimensional array in ruby?
What are the various Ruby runtimes, and how are they different?
What are #method_missing and #send? Why are they useful?
How to shuffle an array in Ruby?
Creating Array with Array.new(size, obj) in Ruby
Ruby program to Calculate the factorial of given number
Ruby program to check whether the given number is prime or not
What's the difference between a lambda, a block and a proc?