Skip to content

Instantly share code, notes, and snippets.

# Curious Number
# n-digit number is said to be curious if the last n digits of
# its square are the same as the original number.
# For example, 25^2 = 625 and 76^2 = 5776.
# (Curious numbers are also known as automorphic numbers.)
# An example of 9 digit number:
# 212890625^2 = 45322418212890625
#Q. Complete the code to return all the curious numbers for n digit
# Curious Number
# n-digit number is said to be curious if the last n digits of
# its square are the same as the original number.
# For example, 25^2 = 625 and 76^2 = 5776.
# (Curious numbers are also known as automorphic numbers.)
# An example of 9 digit number:
# 212890625^2 = 45322418212890625
#Q. Complete the code to return all the curious numbers for n digit
# Curious Number
# n-digit number is said to be curious if the last n digits of
# its square are the same as the original number.
# For example, 25^2 = 625 and 76^2 = 5776.
# (Curious numbers are also known as automorphic numbers.)
# An example of 9 digit number:
# 212890625^2 = 45322418212890625
#Q. Complete the code to return all the curious numbers for n digit
# Curious Number
# n-digit number is said to be curious if the last n digits of
# its square are the same as the original number.
# For example, 25^2 = 625 and 76^2 = 5776.
# (Curious numbers are also known as automorphic numbers.)
# An example of 9 digit number:
# 212890625^2 = 45322418212890625
#Q. Complete the code to return all the curious numbers for n digit
@Saujan
Saujan / happy.rb
Last active October 25, 2019 15:52
HappyNumber
#require 'byebug'
class HappyNumberEngine
attr_accessor :visited_numbers
def initialize
@visited_numbers = [] # the container that collects the visited number.
end
def happy_number_minner(num)
if need_squared?(num) # checking if squaring needed . Allow squaring except for 1.