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