Created
January 7, 2022 12:55
-
-
Save ValeryVerkhoturov/9a140b593f44aa401b4de432ef57367f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private List<PrimeNumber> primesBetween(@Nullable Long from, @NonNull Long to) { | |
| if (from == null || from < MIN_PRIME_VALUE) | |
| from = MIN_PRIME_VALUE; | |
| Map<Long, Boolean> primes = new HashMap<>(); | |
| for (long i = from; i <= to; ++i) { | |
| Boolean isPrime = primes.get(i); | |
| if (isPrime == null || isPrime) | |
| for (long j = MIN_PRIME_VALUE; j <= to; ++j) { | |
| primes.put(i * j, false); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment