Package it.unimi.di.prog2.h14
Class Primes
java.lang.Object
it.unimi.di.prog2.h14.Primes
Iteratore che genera i numeri primi.
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
Il prossimo potenziale numero primo.L'elenco di primi restiuiti da next. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
hasNext()
private boolean
isDivisibleByAFoundPrime
(int n) Verifica sen
è divisibile per un dei primi infoundPrimes
.next()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Field Details
-
candidate
private int candidateIl prossimo potenziale numero primo. -
foundPrimes
L'elenco di primi restiuiti da next.
-
-
Constructor Details
-
Primes
public Primes()
-
-
Method Details
-
hasNext
public boolean hasNext() -
isDivisibleByAFoundPrime
private boolean isDivisibleByAFoundPrime(int n) Verifica sen
è divisibile per un dei primi infoundPrimes
.- Parameters:
n
- il numero da verificare.- Returns:
true
sen
è divisibile per un dei primi già trovati.
-
next
-