Prime numbers from n to m (complete app)
Here are three videos to test the Java interface on the problem
Here are three videos to test the Java interface on the problem:
Stampare i numeri primi tra il limite inferiore e superiore dati in input utilizzando la tua classe myMath collezione dei tuoi metodi e algoritmi matematici studiati a lezione.
The following video is the initial test of the interface. I proceed step by step to verify if the Java app program works.
Rieseguire la lezione per imparare la risoluzione dell’esercizio.
Puoi procedere diversamente dal video ma l’effettività del problema rimane univoca.
https://www.youtube-nocookie.com/embed/O_ByPmWyxAU?origin=http://localhost
The following video develops a class MyMath and the method isprime (method that returns true if the number is prime otherwise false)
https://www.youtube-nocookie.com/embed/eihs3Iz49Kg?origin=http://localhost
The exercise is not yet finished. The goal is to print the prime numbers from n to m
Il passo che faccio intermedio è quello di stampare tutti i numeri da n a m …solo in seguito dirò con l’istruzione isprime se è un primo oppure no.
public boolean IsPrime(int n)
{ // ipotizzo che tutti i numeri siano primi
// poi cerco le contraddizioni
boolean bPrime=true;
int fat=2;
while (fat<=(n/2) )
{
if (n%fat==0)
{
bPrime=false;
}
fat++;
}
return bPrime;
}
https://www.youtube-nocookie.com/embed/MjtPKas5LJM?origin=http://localhost
ecco la soluzione funzionante al problema
Segue il codice complessivo che ti consiglio di non installare! Esegui l’esercizio guardando il video!
../img/isprimeconInterfaccia.zip