How do I generate a random 10 digit number in ruby?

To generate the number call rand with the result of the expression “10 to the power of 10”

rand(10 ** 10)

To pad the number with zeros you can use the string format operator

'%010d' % rand(10 ** 10)

or the rjust method of string

rand(10 ** 10).to_s.rjust(10,'0')  

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)