NumberTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Numbers : NumberTheory/IthFermat

NumberTheory

  

IthFermat

  

Fermat numbers

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

IthFermat(i)

IthFermat(i, output)

Parameters

i

-

non-negative integer

output

-

(optional) equation of the form output=format where format can be value, prime, completelyfactored, factors, record, or a list of these terms.

Description

• 

The IthFermat(i) command returns the ith Fermat number.

• 

Fermat numbers are of the form 22i+1 where i is a non-negative integer.

• 

The output option specifies the format of the returned solution. This option can be an equation of the form output=format or output=list, where format can be any one of the following:

– 

value : Returns the value of the ith Fermat number. This is the default output format.

– 

prime : Returns true, false, or FAIL, depending on whether the primality of the ith Fermat is known.

– 

completelyfactored : Returns true, false or FAIL depending on whether the ith fermat has been completely factored or not. If FAIL is returned, the character of the ith Fermat is unknown.

– 

factors : Returns the prime factors for the ith Fermat number, if they are known. If the ith Fermat number is prime, [] is returned. Otherwise, the factors are unknown.

– 

record : Returns a record containing all of the above output options. Each of the outputs can be queried using :-outputname.

Alternatively, output can be set to a list containing  any of these formats. In this case, a sequence corresponding to the formats in the list is returned. Note that the output option is effective only if the parameter i is an integer; in all other cases, it is ignored.

Examples

withNumberTheory:

The IthFermat command returns the value of the ith Fermat number:

IthFermat0

3

(1)

Fermat numbers are of the form 22i+1:

220+1

3

(2)

There are five known prime Fermat numbers:

seqIthFermati,i=0..4

3,5,17,257,65537

(3)

More details on Fermat numbers can be found using the output option:

IthFermat1,output=prime

true

(4)

To get more information about a given Fermat number, use the list form of the output option.

IthFermat3,output=prime,value,completelyfactored

true,257,true

(5)

Most Fermat numbers are composite. A full record of information can be returned using record as the output option:

F__5IthFermat5,output=record

F__5Recordvalue=4294967297,prime=false,completelyfactored=true,factors=275+127317449+1

(6)

F__5:-value

4294967297

(7)

F__5:-prime

false

(8)

F__5:-factors

275+127317449+1

(9)

Check a known factor of F_49093.  (Use expand to undo the factorisation of the factor.)

fIthFermat49093,'output'='factors'

f165249095+1

(10)

fexpandf1:

2 &^ 249093+1modf

0

(11)

Data frames are useful for capturing information about Fermat numbers:

FermatDFn→DataFrameseq2`2`i+1,i∈n|seqlengthIthFermati,i∈n|seqIthFermati,output=prime,i∈n|seqIthFermati,output=completelyfactored,i∈n,rows=opn,columns=F__n,`# of digits`,Prime,`Completely Factored`:

Warning, `i` is implicitly declared local to procedure `FermatDF`

FermatDFseq0..7

F__n# of digitsPrimeCompletely Factored031truetrue122+11truetrue2222+12truetrue3223+13truetrue4224+15truetrue5225+110falsetrue6226+120falsetrue7227+139falsetrue

(12)

FermatDF19

F__n# of digitsPrimeCompletely Factored192219+1157827falsefalse

(13)

GetRowFermatDF21,1

F__n2221+1# of digits631306PrimefalseCompletely Factoredfalse

(14)

Compatibility

• 

The NumberTheory[IthFermat] command was introduced in Maple 2017.

• 

For more information on Maple 2017 changes, see Updates in Maple 2017.

See Also

expand

mod

NumberTheory

NumberTheory[IthMersenne]