Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 5 years ago

dan_fulea gravatar image

Simply generate a random nine-digits integer, ten insert a one at the "last" place. Here is a possibility using the random package:

sage: import random                                                                                                                 
sage: a = random.choice(range(10^8, 10^9)) * 10 + 1                                                                                 
sage: a                                                                                                                             
9768350121

Or we offer directly the corresponding range to the random.choice method:

sage: random.choice(range(10^9 + 1, 10^10, 10))                                                          
8455325531

Here, range(10^9 + 1, 10^10, 10)is a range-object, which "consumed" points to the integers taken from 109+1 with step 10 going up to maximally (and excluding) 1010. Then random.choice called with this range instance picks one random element of the corresponding list.

click to hide/show revision 2
No.2 Revision

Simply We can simply generate a random nine-digits integer, ten then insert a one at the "last" place. Here is a possibility using the random package:

sage: import random                                                                                                                 
sage: a = random.choice(range(10^8, 10^9)) * 10 + 1                                                                                 
sage: a                                                                                                                             
9768350121

Or we offer directly the corresponding range to the random.choice method:

sage: random.choice(range(10^9 + 1, 10^10, 10))                                                          
8455325531

Here, range(10^9 + 1, 10^10, 10)is a range-object, which "consumed" points to the integers taken from 109+1 with step 10 going up to maximally (and excluding) 1010. Then random.choice called with this range instance picks one random element of the corresponding list. list.