How do you create a range, that contains all the natural numbers?

found this interesting problem on facebook today? I didn"t know the answer for a while, so I asked Daniel on sf to discuss it and see if there was any answer.

question: how do I create a range, that contains all natural numbers?

Feb.28,2021

you can achieve

by using itertools.count () .

reference: python.org/3/library/itertools.html-sharpitertools.count" rel=" nofollow noreferrer "> https://docs.python.org/3/lib.

 

Natural numbers are infinite, and infinity has no practical meaning at the code implementation level. Or to put it another way, the resources of a computer are limited, and it cannot fully accommodate an infinite concept.
if you don't think about resources, just think about implementation, it's easy to define an iterable object in Python, and it's over with + 1 each time.
keep it simple, just use xrange, xrange (1, sys.maxint) .

in addition, the original text refers to numbers, not natural numbers.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54c93-44a69.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54c93-44a69.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?