Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/utils/doc/   (GAP Algebra Version 4.15.1©)  Datei vom 11.8.2025 mit Größe 5 kB image not shown  

Quelle  number.xml

  Sprache: XML
 

<!-- ------------------------------------------------------------------- -->
<!--                                                                     -->
<!--  number.xml          Utils documentation                Stefan Kohl -->
<!--                                                                     -->
<!--  Copyright (C) 2015-2025, The GAP Group,                            -->
<!--                                                                     -->
<!-- ------------------------------------------------------------------- -->

<?xml version="1.0" encoding="UTF-8"?>

<Chapter Label="chap-number">
<Heading>Number-theoretic functions</Heading>



<Section Label="sec-integers">
<Heading>Functions for integers</Heading>


<ManSection>
   <Func Name="AllSmoothIntegers"
         Arg="maxp maxn" Label="for two integers" />
   <Func Name="AllSmoothIntegers"
         Arg="L maxp" Label="for a list and an integer" />
<Description>
This function has been transferred from package &RCWA;. 
<P/>
<Index>smooth integer</Index> 
The function <C>AllSmoothIntegers(<A>maxp</A>,<A>maxn</A>)</C>
returns the list of all positive integers less than or equal to <A>maxn</A> 
whose prime factors are all in the list 
<M>L = \{p ~|~ p \leqslant maxp, p~\mbox{prime} \}</M>.  
<P/>
In the alternative form, when <M>L</M> is a list of primes, 
the function returns the list of all positive integers 
whose prime factors lie in <M>L</M>. 
<P/>
</Description>
</ManSection>
<Example>
<![CDATA[
gap> AllSmoothIntegers( 31000 );
123468912161824273236485464728196
  108128144162192216243256288324384432486512576
  648729768864972 ]
gap> AllSmoothIntegers( [5,11,17], 1000 );
151117255585121125187275289425605625935 ]
gap> Length( last );
16
gap> List( [3..20], n -> Length( AllSmoothIntegers( [5,11,17], 10^n ) ) );
162950781141552122823594525656918319921173
  137415951843 ]
]]>
</Example>

<ManSection>
   <Func Name="AllProducts"
         Arg="L, k" />
<Description>
This function has been transferred from package &RCWA;. 
<P/>
The command <C>AllProducts(<A>L</A>,<A>k</A>)</C> returns the list of
all products of <A>k</A> entries of the list <A>L</A>. 
Note that every ordering of the entries is used so that, in the commuting case, 
there are bound to be repetitions.  
<P/>
</Description>
</ManSection>
<Example>
<![CDATA[
gap> AllProducts([1..4],3); 
123424683691248121624684812
  166121824816243236912612182491827
  36122436484812168162432122436481632
  4864 ]
gap> Set(last);            
1234689121618242732364864 ]
gap> AllProducts( [(1,2,3),(2,3,4)], 2 );
[ (2,4,3), (1,2)(3,4), (1,3)(2,4), (1,3,2) ]
]]>
</Example>

<ManSection>
   <Func Name="RestrictedPartitionsWithoutRepetitions"
         Arg="n,S" />
<Description>
This function has been transferred from package &RCWA;. 
<P/>
For a positive integer <A>n</A> and a set of positive integers <A>S</A>, 
this function returns the list of partitions of <A>n</A> 
into distinct elements of <A>S</A>.
Unlike <C>RestrictedPartitions</C>, no repetitions are allowed.
<P/>
</Description>
</ManSection>
<Example>
<![CDATA[
gap> RestrictedPartitions( 20, [4..10] );
[ [ 44444 ], [ 5555 ], [ 6554 ], [ 6644 ], 
  [ 7544 ], [ 776 ], [ 8444 ], [ 866 ], [ 875 ], 
  [ 884 ], [ 965 ], [ 974 ], [ 1055 ], [ 1064 ], 
  [ 1010 ] ]
gap> RestrictedPartitionsWithoutRepetitions( 20, [4..10] );
[ [ 1064 ], [ 974 ], [ 965 ], [ 875 ] ]
gap> RestrictedPartitionsWithoutRepetitions( 10^2, List([1..10], n->n^2 ) );
[ [ 100 ], [ 6436 ], [ 49251691 ] ]
]]>
</Example>

<ManSection>
   <Func Name="NextProbablyPrimeInt"
         Arg="n" />
<Description>
This function has been transferred from package &RCWA;. 
<P/>
The function <C>NextProbablyPrimeInt(<A>n</A>)</C> 
does the same as <C>NextPrimeInt(<A>n</A>)</C> 
except that for reasons of performance it tests numbers only for
<C>IsProbablyPrimeInt(<A>n</A>)</C> instead of <C>IsPrimeInt(<A>n</A>)</C>.
For large <A>n</A>, this function is much faster than 
<C>NextPrimeInt(<A>n</A>)</C> 
<P/>
</Description>
</ManSection>
<Example>
<![CDATA[
gap> n := 2^251;
3618502788666131106986593281521497120414687020801267626233049500247285301248
gap> NextProbablyPrimeInt( n );
3618502788666131106986593281521497120414687020801267626233049500247285301313
gap> time;                     
1
gap> NextPrimeInt( n );        
3618502788666131106986593281521497120414687020801267626233049500247285301313
gap> time;             
213
]]>
</Example>

<ManSection>
   <Func Name="PrimeNumbersIterator"
         Arg="[chunksize]" />
<Description>
This function has been transferred from package &RCWA;. 
<P/>
This function returns an iterator which runs over the prime numbers 
n ascending order; it takes an optional argument <C>chunksize</C> 
which specifies the length of the interval which is sieved in one go 
(the default is <M>10^7</M>), 
and which can be used to balance runtime vs. memory consumption. 
It is assumed that <C>chunksize</C> is larger than any gap between two 
consecutive primes within the range one intends to run the iterator over. 
<P/>
</Description>
</ManSection>
<Example>
<![CDATA[
gap> iter := PrimeNumbersIterator();;
gap> for i in [1..100] do  p := NextIterator(iter);  od;
gap> p;
541
gap> sum := 0;;
gap> ## "prime number race" 1 vs. 3 mod 4
gap> for p in PrimeNumbersIterator() do 
>       if p <> 2 then sum := sum + E(4)^(p-1); fi;
>       if sum > 0 then break; fi;
>    od;
gap> p;
26861
]]>
</Example>


</Section>


</Chapter>

Messung V0.5 in Prozent
C=96 H=100 G=97

¤ Dauer der Verarbeitung: 0.22 Sekunden  (vorverarbeitet am  2026-06-05) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.