AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language probedivision -abbruch von schleife funktioniert nicht
Thema durchsuchen
Ansicht
Themen-Optionen

probedivision -abbruch von schleife funktioniert nicht

Ein Thema von qwertz543221 · begonnen am 8. Okt 2009 · letzter Beitrag vom 8. Okt 2009
 
qwertz543221
(Gast)

n/a Beiträge
 
#1

probedivision -abbruch von schleife funktioniert nicht

  Alt 8. Okt 2009, 18:00
ich möchte folgende proceudre (probedivision)abrrechen und mit dem restlichen code weitermachen, doch wieso kann ich die schleife nicht beenden, wenn die abbruchbedingung erreicht ist?
Delphi-Quellcode:
function tform1.miller_rabin(n: ansistring; t: longint):boolean;
label l;
var
  n1,n2, y, r, x: string;
  s,j,i: longint;
const
 primes:array[1..5]of string=('2','3','5','7');//in meinem fall deujtlich größer
   // probedivison
function probedivision(n:ansistring):boolean;
var
 I:longint;
begin
i:=1;
result:=true;
while i<=5{9549} do
begin
if mathe.modulo(n,primes[i])='0'
 then
 begin
 result:=false;
 break;
 end
   else i:=i+1;
end;
end;

begin
result := false;
if Mathe.istGerade(n)
  then exit;

begin
{get n1 = n - 1} 
{get n2 = n - 2}
if probedivision(n)=true
 then
  begin
  n1 := n;
  Mathe.Minus1(n1);
  n2 := n1;
  Mathe.Minus1(n2);

  {calculate r,s with n-1=2^s*r} 
  r := n1;
  s := 0;
  while Mathe.istGerade(r) do
   begin
   r := Mathe.Quotient(r,'2');
   inc(s);
   end;
   while t>0 do
   begin
    {generate a in the range 2<=a<n-1, calculate y = a^r mod n}
    y := Mathe.Zufallszahl('2', n2);
    y := Mathe.PotenzModulo(y,r,n);
    {if y<>1 and y<>n-1 do}
    if (y<>'1') and (y<>n1)
     then
     begin
     j := 1;
     while (j <= s-1) and (y<>n1) do
     begin
     y := Mathe.ProduktModulo(y,y,n);
     {if y=1 then composite} 
     if y='1
      then exit;
     inc(j);
     end;
      {if y<>n1 then composite} 
      if y<>n1 then exit;
    end;
    dec(t);
  end;
  {probably prime now}
  result := true;
end;
end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz