Autor Beitrag
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 10.09.04 12:18 
@thebe falsch!

bei meiner routine beginnt der wenn man von 44 die primfaktorzerlegung amcht bei
22 -> 44 mod 22 = 0 also

44 div 22 = 2 in die liste

dann macht der weiter mit 22

da beginnt der bei 11

22 mod 11 = 0 also
22 div 11 = 2 in die liste

dann macht der mit 11 weiter, da gibbet keinen teiler also in die liste...

teste doch plz die funktion bevor du behauptest die funzt net. Danke. :)

EDIT

macht man aus meiner downto schleife ne to schleife dann ist meine funktion 3 mal schneller als die von thebe

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
function zerlege(i: integer): string;
var s: string;
  procedure zz(a: integer);
  var i: integer;
  begin
    for i := 2 to (a div 2) do
    begin
      if (a mod i = 0) then
      begin
        s := s+inttostr(i)+'*';
        zz(a div i);
        exit;
      end;
    end;
    s := s+inttostr(a);
  end;
begin
  zz(i);
  if pos('*',s) = 0 then s := 'primzahl';
  result := s;
end;
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 10.09.04 16:27 
Also funktionert haben alle Routinen im Test.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
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: Fr 10.09.04 19:49 
Welche war die schnellste?

_________________
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.
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 10.09.04 19:58 
.Chef hat folgendes geschrieben:
thebe: 10 Punkte! Der schnellste Algo, dazu Pluspunkte für die Rekursion und kurz isser auch noch ...

...

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 11.09.04 10:04 
NEIN meine letzte is schneller asl die von thebe !!!! :)
2-3 mal so schnell, habe es getestet @ .Chef
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Sa 11.09.04 10:33 
So? Na dann teste mal mit einer Zahl wie 2195125920. Da erhalte ich nämlich ein ganz anderes Ergebnis!

Edit: Achso, deine allerletzte meinst du? Die wurde aber erst nach dem Einsendeschluss veröffentlicht. Wer zu spät kommt, den bestraft das Leben...

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 11.09.04 10:45 
hm k *heul* ;)