Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Fondamenti di architettura e programmazione > [Esercizio] CalcoloPrimi
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
supernova
Mad For It

User info:
Registered: May 2003
Posts: 403 (0.05 al dì)
Location: Milan, London
Corso: Digital Comunication
Anno: I Don't Know, Not Yet.
Time Online: 3 Days, 4:56:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Esercizio CalcoloPrimi

Raga vi è uscito l'esercizio CalcoloPrimi?

Ho sostituito il while con il do while per il controllo della primalità così:

do {
if (p%div==0) primo = false;
else div++;
} while ((div <= Math.sqrt(p)) && primo);

Il programma va, solo che non mi stampa il numero 2 come numero primo e come centesimo numero primo mi da 541 (che sarebbe il 101esimo) invece di 523.

Qualcuno mi può aiutare?

:? :? :? :? :? :)

__________________
" So I Start The Revolution From My Bed ". Noel Gallagher

09-11-2003 23:52
Click Here to See the Profile for supernova Click here to Send supernova a Private Message Find more posts by supernova Add supernova to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
foolish
bleak

User info:
Registered: Oct 2003
Posts: 3585 (0.46 al dì)
Location:
Corso:
Anno:
Time Online: 36 Days, 7:28:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Re: Esercizio CalcoloPrimi

Originally posted by supernova
Raga vi è uscito l'esercizio CalcoloPrimi?

Ho sostituito il while con il do while per il controllo della primalità così:

do {
if (p%div==0) primo = false;
else div++;
} while ((div <= Math.sqrt(p)) && primo);

Il programma va, solo che non mi stampa il numero 2 come numero primo e come centesimo numero primo mi da 541 (che sarebbe il 101esimo) invece di 523.

Qualcuno mi può aiutare?

:? :? :? :? :? :)


il programma che bisogna modificare fa partire il controllo dal numero 2.
Dunque 2 mod 2 e' 0 e quindi il programma legge il numero 2 come NON PRIMO!

quindi poni 2 come numero primo fin dall'inizio( lo scrivi tu come si fa per uno)

poi il conteggio deve partire quindi da 2 (2 numeri sono gia' stampati di default).

Poi dovrebbe tutto funzionare.
:approved:

__________________
The only way to discover the limits of the possible is to go beyond them into the impossible.
Arthur C. Clarke.

10-11-2003 15:12
Click Here to See the Profile for foolish Click Here to See the Blog of foolish Click here to Send foolish a Private Message Find more posts by foolish Add foolish to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
REQUIEM
TYPE A SECETOR

User info:
Registered: Jun 2006
Posts: 1102 (0.16 al dì)
Location:
Corso:
Anno:
Time Online: 53 Days, 5:38:53 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

cmq non è possibile che siano x il 14 cazzo!!!

domani chiediamo delucidazioni a Malchiodi

10-11-2003 16:45
Click Here to See the Profile for REQUIEM Click Here to See the Blog of REQUIEM Click here to Send REQUIEM a Private Message Find more posts by REQUIEM Add REQUIEM to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
supernova
Mad For It

User info:
Registered: May 2003
Posts: 403 (0.05 al dì)
Location: Milan, London
Corso: Digital Comunication
Anno: I Don't Know, Not Yet.
Time Online: 3 Days, 4:56:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ma bella Foolish, il programma mi va ora!

__________________
" So I Start The Revolution From My Bed ". Noel Gallagher

10-11-2003 17:56
Click Here to See the Profile for supernova Click here to Send supernova a Private Message Find more posts by supernova Add supernova to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 15:11.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.041 seconds (80.38% PHP - 19.62% MySQL) con 29 query.