Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/standardff/lib/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 13.8.2023 mit Größe 1 kB image not shown  

Quelle  generateCANFACT.g   Sprache: unbekannt

 
##############################################################################
##
#A  generateCANFACT.g                                             Frank Lübeck
##
##  This file can be read by GAP to produce an update of the list 'CANFACT' in
##  'CANFACT.g'. For example after an update of the list of Brent factors, see
##  '?FetchMoreFactors'.
##  
##  The idea is to fork GAP instances which try for 5 seconds to factorize p^n
##  - 1. If successful the pair (p,n) is included in CANFACT.
##


SetInfoLevel( InfoPrimeInt, 0 );
out := OutputTextFile("CANFACT", false);
SetPrintFormattingStatus(out, false);
AppendTo(out, "CANFACT := [];\n");
for p in Filtered([1..10000], IsPrime)  do
  Print(p," [\c");
  if p < 10 then
    max := 2000;
  elif p < 100 then 
    max := 500;
  else 
    max := 100;
  fi;
  AppendTo(out, "CANFACT[",p,"]:=[];\n");
  l := [];
  for n in [1..max] do
    Print([p,n]," \c");
    pf := ParTakeFirstResultByFork([Factors],[[p^n-1]],
          rec(TimeOut:=rec(tv_sec:=5,tv_usec:=0)));
    if Length(pf) > 0 then
      AppendTo(out, "Add(CANFACT[",p,"],",n,");\n");
    fi;
  od;
od;
CloseStream(out);
Print("""Read the file 'CANFACT' and print the variable CANFACT to the file
    CANFACT.g
to store the data more compactly.
""");




[ Dauer der Verarbeitung: 0.6 Sekunden  (vorverarbeitet)  ]