Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def nextl(i)
- if lucky(i)
- i.to_i
- else
- multiply = true
- (i.length - 1).downto(0) do |j|
- if i[j] < '4'
- i[j] = '4'
- multiply = false
- elsif i[j] >= '4' and i[j] < '7'
- i[j] = '7'
- multiply = false
- break
- elsif i[j] > '7'
- i[j] = '4'
- end
- end
- if multiply
- i = "4" * (i.length + 1)
- end
- i.to_i
- end
- end
Add Comment
Please, Sign In to add comment