Skip to content

Instantly share code, notes, and snippets.

View prabes's full-sized avatar
🎯
Upgrading . . .

Prabesh Dahal prabes

🎯
Upgrading . . .
View GitHub Profile
@prabes
prabes / Curious_number.rb
Created November 7, 2019 15:02
This ruby script prints all the curious number upto 'n'th digits.
# This algorithm only works upto 23 digits.
# As I found 10**9942066 is the maximum calculation ruby can perform without overflowing into infinity
# ie, any number greater than 109942066 will overflow to infinity.
class CuriousNumber
def calculate(i)
a = 5**(2**i) % 10**i
b = (10**i)+1 - a
@prabes
prabes / happy_number.rb
Created October 26, 2019 05:55
This ruby script takes a number and checks the number is happy or not.
#require 'byebug'
puts "Enter a number:"
number = gets.chomp.to_i
#method takes sum of square and an array
def happy square_sum, array=[]
#gets individual number in an array
num = square_sum.digits