Big Billion Prrinting in Python
Big Billion Prrinting in Python
https://www.pythoncentral.io/how-to-use-pythons-xrange-and-range/
https://stackoverflow.com/questions/15238250/fastest-way-to-count-up-to-1-billion-in-python
2
Usually, if you need to iterate up to 1000000000, there's some better way. For example, you can
use some mathematical property to avoid testing every number:
you are adding a huge number of elements to a list, then consider using
a generatorinstead. This will avoid the overhead of creating a massive list, while still
being useful for many things
def gen_numbers(n):
for i in range(n):
if <i passes test>:
yield i
for i in gen_numbers(1000000000):
print(i)
-----------------------------------------------------------------------------------------------------------------------------------