Not complete sure but pretty sure ! But not significant notable in computing time, few tenths of seconds.There are 1229 prime numbers between 1 and 10,000.
#List of prime numbers to 1000000 code#
While all primes before \(\displaystyle i^2\) already have been filtered (similar like code previous message). I think the line: "is_prime=False" can be optimized to: "is_prime=False". the first \(\displaystyle 144.000.000\) prime numbers. For \(\displaystyle x=3*10^9\) you will get approx. See prime counting function \(\displaystyle \pi(x)=x/ln(x)\): Wiki. So if you fill in \(\displaystyle 10^9\) you will get the first \(\displaystyle 50.000.000\) primes (approximately). Change number \(\displaystyle x\) to determine primes till that integer. The programline: "generate_primes(\(\displaystyle x\))" generates the primes. If you want to experiment with Python download: "Anaconda Python" a total package with several programs, open Anaconda navigator and start "Spyder" that is a Python compiler and program should work.Ĭode is based upon topic: Stackoverflow.
![list of prime numbers to 1000000 list of prime numbers to 1000000](https://i.ytimg.com/vi/paJAz0wm_Yw/hqdefault.jpg)
![list of prime numbers to 1000000 list of prime numbers to 1000000](https://i.ytimg.com/vi/BWAj1y5Riz4/hqdefault.jpg)
It might be better to save as other format (see numpy save methods) depending upon your requirements. The text data file is rather big \(\displaystyle 1.6\) GB, but I could open it with notepad++.
![list of prime numbers to 1000000 list of prime numbers to 1000000](https://d138zd1ktt9iqe.cloudfront.net/media/seo_landing_files/prime-numbers-from-1-to-1000-1619769948.png)
Primes are separated with carriage return but you can change that in code ('\n'). It created a textfile of the first: \(\displaystyle 144.000.000\) prime numbers within \(\displaystyle 242\) seconds on my computer. I found and adapted a easy piece of code (Python), program uses numpy (standard available in most Python packages).