Guest User

Untitled

a guest
Feb 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.42 KB | None | 0 0
  1. def nextl(i)
  2.   if lucky(i)
  3.     i.to_i
  4.   else
  5.     multiply = true
  6.     (i.length - 1).downto(0) do |j|
  7.       if i[j] < '4'
  8.         i[j] = '4'
  9.         multiply = false
  10.       elsif i[j] >= '4' and i[j] < '7'
  11.         i[j] = '7'
  12.         multiply = false
  13.         break
  14.       elsif i[j] > '7'
  15.         i[j] = '4'
  16.       end
  17.     end
  18.  
  19.     if multiply
  20.       i = "4" * (i.length + 1)
  21.     end
  22.  
  23.     i.to_i
  24.   end
  25. end
Add Comment
Please, Sign In to add comment