Efficient Prime Numbers in Python

preview_player
Показать описание
This video shows how to write an efficient isPrime function in Python for determining if a number is prime or not.
Рекомендации по теме
Комментарии
Автор

All prime numbers > 3 have either the form 6k+5 (k>=0) or 6k+1 (k>=1). Therefore you can filter the "numbers beyond all primes list", and you get rid of 2/3 of occurrences. I tested many prime programs in python and i have many ideas. I can generate all primes up to in 0.022 secs and detect primes of 17 digits in only 7.23 secs.

marcoshenriques
Автор

you only have to loop through the range 2, x//2+1

hawk
Автор

nice work ... primes are underrated lol

koufdell