NumberTheory - Maple Programming Help

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

NumberTheory

 IthFermat
 Fermat numbers

 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 ${2}^{{2}^{i}}+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

 > $\mathrm{with}\left(\mathrm{NumberTheory}\right):$

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

 > $\mathrm{IthFermat}\left(0\right)$
 ${3}$ (1)

Fermat numbers are of the form ${2}^{{2}^{i}}+1$:

 > ${2}^{{2}^{0}}+1$
 ${3}$ (2)

There are five known prime Fermat numbers:

 > $\mathrm{seq}\left(\mathrm{IthFermat}\left(i\right),i=0..4\right)$
 ${3}{,}{5}{,}{17}{,}{257}{,}{65537}$ (3)

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

 > $\mathrm{IthFermat}\left(1,\mathrm{output}=\mathrm{prime}\right)$
 ${\mathrm{true}}$ (4)

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

 > $\mathrm{IthFermat}\left(3,\mathrm{output}=\left[\mathrm{prime},\mathrm{value},\mathrm{completelyfactored}\right]\right)$
 ${\mathrm{true}}{,}{257}{,}{\mathrm{true}}$ (5)

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

 > $\mathrm{F__5}≔\mathrm{IthFermat}\left(5,\mathrm{output}=\mathrm{record}\right)$
 $\mathrm{F__5}{≔}{\mathrm{Record}}{}\left({\mathrm{value}}{=}{4294967297}{,}{\mathrm{prime}}{=}{\mathrm{false}}{,}{\mathrm{completelyfactored}}{=}{\mathrm{true}}{,}{\mathrm{factors}}{=}\left[\left({\left({2}\right)}^{{7}}{}\left({5}\right){+}{1}\right){}\left({\left({2}\right)}^{{7}}{}\left({3}\right){}\left({17449}\right){+}{1}\right)\right]\right)$ (6)
 > $\mathrm{F__5}:-\mathrm{value}$
 ${4294967297}$ (7)
 > $\mathrm{F__5}:-\mathrm{prime}$
 ${\mathrm{false}}$ (8)
 > $\mathrm{F__5}:-\mathrm{factors}$
 $\left[\left({\left({2}\right)}^{{7}}{}\left({5}\right){+}{1}\right){}\left({\left({2}\right)}^{{7}}{}\left({3}\right){}\left({17449}\right){+}{1}\right)\right]$ (9)

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

 > $f≔\mathrm{IthFermat}\left(49093,'\mathrm{output}'='\mathrm{factors}'\right)$
 ${f}{≔}\left[\left({3}\right){}\left({5}\right){}\left({11}\right){}{\left({2}\right)}^{{49095}}{+}{1}\right]$ (10)
 > $f≔\mathrm{expand}\left(f\left[1\right]\right):$
 > $2\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}&ˆ\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left({2}^{49093}\right)+1\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{mod}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}f$
 ${0}$ (11)

Data frames are useful for capturing information about Fermat numbers:

 > $\mathrm{FermatDF}≔n↦\mathrm{DataFrame}\left(⟨⟨\mathrm{seq}\left({2}^{{\mathrm{2}}^{i}}+1,i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\right)⟩|⟨\mathrm{seq}\left(\mathrm{length}\left(\mathrm{IthFermat}\left(i\right)\right),i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\right)⟩|⟨\mathrm{seq}\left(\mathrm{IthFermat}\left(i,\mathrm{output}=\mathrm{prime}\right),i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\right)⟩|⟨\mathrm{seq}\left(\mathrm{IthFermat}\left(i,\mathrm{output}=\mathrm{completelyfactored}\right),i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\right)⟩⟩,\mathrm{rows}=\left[\mathrm{op}\left(n\right)\right],\mathrm{columns}=\left[\mathrm{F__n},\mathrm{# of digits},\mathrm{Prime},\mathrm{Completely Factored}\right]\right):$
 > $\mathrm{FermatDF}\left(\left[\mathrm{seq}\left(0..7\right)\right]\right)$
 $\left[\begin{array}{ccccc}{}& \mathrm{F__n}& {\mathrm{# of digits}}& {\mathrm{Prime}}& {\mathrm{Completely Factored}}\\ {0}& {3}& {1}& {\mathrm{true}}& {\mathrm{true}}\\ {1}& {{2}}^{{2}}{+}{1}& {1}& {\mathrm{true}}& {\mathrm{true}}\\ {2}& {{2}}^{{{2}}^{{2}}}{+}{1}& {2}& {\mathrm{true}}& {\mathrm{true}}\\ {3}& {{2}}^{{{2}}^{{3}}}{+}{1}& {3}& {\mathrm{true}}& {\mathrm{true}}\\ {4}& {{2}}^{{{2}}^{{4}}}{+}{1}& {5}& {\mathrm{true}}& {\mathrm{true}}\\ {5}& {{2}}^{{{2}}^{{5}}}{+}{1}& {10}& {\mathrm{false}}& {\mathrm{true}}\\ {6}& {{2}}^{{{2}}^{{6}}}{+}{1}& {20}& {\mathrm{false}}& {\mathrm{true}}\\ {7}& {{2}}^{{{2}}^{{7}}}{+}{1}& {39}& {\mathrm{false}}& {\mathrm{true}}\end{array}\right]$ (12)
 > $\mathrm{FermatDF}\left(19\right)$
 $\left[\begin{array}{ccccc}{}& \mathrm{F__n}& {\mathrm{# of digits}}& {\mathrm{Prime}}& {\mathrm{Completely Factored}}\\ {19}& {{2}}^{{{2}}^{{19}}}{+}{1}& {157827}& {\mathrm{false}}& {\mathrm{false}}\end{array}\right]$ (13)
 > $\mathrm{GetRow}\left(\mathrm{FermatDF}\left(21\right),1\right)$
 $\left[\begin{array}{cc}\mathrm{F__n}& {{2}}^{{{2}}^{{21}}}{+}{1}\\ {\mathrm{# of digits}}& {631306}\\ {\mathrm{Prime}}& {\mathrm{false}}\\ {\mathrm{Completely Factored}}& {\mathrm{false}}\end{array}\right]$ (14)

Compatibility

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