IsPrimitive - Maple Help

# Online Help

###### All Products    Maple    MapleSim

StringTools

 IsPrimitive
 test whether a string is primitive

 Calling Sequence IsPrimitive( s )

Parameters

 s - string

Description

 • The IsPrimitive(s) command returns the value true if s is primitive, and the value false otherwise. A string is primitive if it cannot be written as a proper power of another string. In other words, s is primitive if $\mathrm{Repeat}\left(t,n\right)=s$ implies that either $s=""$ or $s=t$ and $n=1$.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{IsPrimitive}\left(""\right)$
 ${\mathrm{false}}$ (1)
 > $\mathrm{IsPrimitive}\left("a"\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{IsPrimitive}\left("aaa"\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{IsPrimitive}\left("abc"\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{IsPrimitive}\left("abcabc"\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{seq}\left(\mathrm{IsPrimitive}\left(\mathrm{ThueMorse}\left(n\right)\right),n=1..30\right)$
 ${\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}$ (6)
 > $\mathrm{andmap}\left(\mathrm{IsPrimitive},\mathrm{LyndonFactors}\left(\mathrm{Random}\left(1000,'\mathrm{lower}'\right)\right)\right)$
 ${\mathrm{true}}$ (7)

 See Also