Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/utils/doc/   (Algebra von RWTH Aachen 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( 3, 1000 );
[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 54, 64, 72, 81, 96, 
  108, 128, 144, 162, 192, 216, 243, 256, 288, 324, 384, 432, 486, 512, 576, 
  648, 729, 768, 864, 972 ]
gap> AllSmoothIntegers( [5,11,17], 1000 );
[ 1, 5, 11, 17, 25, 55, 85, 121, 125, 187, 275, 289, 425, 605, 625, 935 ]
gap> Length( last );
16
gap> List( [3..20], n -> Length( AllSmoothIntegers( [5,11,17], 10^n ) ) );
[ 16, 29, 50, 78, 114, 155, 212, 282, 359, 452, 565, 691, 831, 992, 1173, 
  1374, 1595, 1843 ]
]]>
</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); 
[ 1, 2, 3, 4, 2, 4, 6, 8, 3, 6, 9, 12, 4, 8, 12, 16, 2, 4, 6, 8, 4, 8, 12, 
  16, 6, 12, 18, 24, 8, 16, 24, 32, 3, 6, 9, 12, 6, 12, 18, 24, 9, 18, 27, 
  36, 12, 24, 36, 48, 4, 8, 12, 16, 8, 16, 24, 32, 12, 24, 36, 48, 16, 32, 
  48, 64 ]
gap> Set(last);            
[ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 32, 36, 48, 64 ]
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] );
[ [ 4, 4, 4, 4, 4 ], [ 5, 5, 5, 5 ], [ 6, 5, 5, 4 ], [ 6, 6, 4, 4 ], 
  [ 7, 5, 4, 4 ], [ 7, 7, 6 ], [ 8, 4, 4, 4 ], [ 8, 6, 6 ], [ 8, 7, 5 ], 
  [ 8, 8, 4 ], [ 9, 6, 5 ], [ 9, 7, 4 ], [ 10, 5, 5 ], [ 10, 6, 4 ], 
  [ 10, 10 ] ]
gap> RestrictedPartitionsWithoutRepetitions( 20, [4..10] );
[ [ 10, 6, 4 ], [ 9, 7, 4 ], [ 9, 6, 5 ], [ 8, 7, 5 ] ]
gap> RestrictedPartitionsWithoutRepetitions( 10^2, List([1..10], n->n^2 ) );
[ [ 100 ], [ 64, 36 ], [ 49, 25, 16, 9, 1 ] ]
]]>
</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>

89%


¤ Dauer der Verarbeitung: 0.30 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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 ist noch experimentell.