Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 19.11.06 14:48 
Ich möchte prüfen, ob eine Zahl Primzahl ist.
Dazu schließe ich aus, dass diese durch 2, 3, 5 und 7 teilbar ist. Ist damit alles getan?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Der_Neue
Hält's aus hier
Beiträge: 12

Win XP Prof
D7 Ent, D2005 Per
BeitragVerfasst: So 19.11.06 14:51 
Nein , du musst prüfen ob X (Primzahl) durch die Zahlen 2 bis 1/2 X teilbar ist.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 19.11.06 14:54 
Aber wenn ich die vier genannten als Teiler ausschließe, dann schließe ich doch auch alle anderen aus, da diese doch auf diesen vier Zahlen basieren. Z.B. kann ich 603 ausschließen, wenn ich 3 ausschließen kann usw.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 19.11.06 15:00 
Und wie schließt du aus, dass eine Zahl durch 17 teilbar ist?
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: So 19.11.06 15:02 
user profile iconDer_Neue hat folgendes geschrieben:
Nein , du musst prüfen ob X (Primzahl) durch die Zahlen 2 bis 1/2 X teilbar ist.

Falsch,
bis Quadratwurzel von x reicht aus.

@user profile iconMarco D. was ist mit 121? Du musst x mit JEDER gefundenen Primzahl bis Quadratwurzel von x prüfen.
Es gibt aber noch das Sieb des ??? (keine Ahnung wieder der antike Herr hieß, meine etwas mit E).
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 19.11.06 15:10 
Ok ihr habt gewonnen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 19.11.06 15:23 
user profile iconTilo hat folgendes geschrieben:
Es gibt aber noch das Sieb des ??? (keine Ahnung wieder der antike Herr hieß, meine etwas mit E).

Sieb des Erastosthenes

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 19.11.06 18:49 
Zu diesem Thema gibt es unter Algorithmen, ASM und Opti auch noch einige weitere Algos. U.a. das Primzahlrad und so'n Sieb von nem Typen mit A :P

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 19.11.06 20:40 
Ich liebe diesen Thread:
www.delphi-forum.de/viewtopic.php?t=33013
Das waren noch Zeiten, als man auf 13 Seiten versucht hat immer besser zu optimieren...

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)