defis_happy?(number)tmp=[]while(number>1)&&(!tmp.include?(number))tmp<<number# with ruby >=2.4 you can use number.digitsdigits=number.to_s.chars.map(&:to_i)number=digits.inject(0){|total,value|total+=value**2}endnumber==1end
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is a ruby implementation.