brewersfan1976

champernowne_digit.rb

Sep 21st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.28 KB | None | 0 0
  1. def champernowneDigit(n)
  2.     string = ""
  3.     x = 1
  4.    
  5.     while (x <= n)
  6.           string = string + x.to_s
  7.           x = x + 1
  8.     end
  9.    
  10.     x = 0
  11.    
  12.     while (x < n)
  13.           output = string[x].to_i
  14.           x = x + 1
  15.     end
  16.    
  17.     return output
  18. end
Advertisement
Add Comment
Please, Sign In to add comment