< ^ From:

> < ^ Subject:

Dear Forum,

saad bedaiwi wrote:

Let L be a list of integers, is there a way to test whether each member of L

is a power of a

specific prime, it seems that the command "IsPrimePowerInt" do

that but for an arbitrary prime

Yes, you can do the following:

Define a function ...

OnlyPowersOfp := function ( L, p ) return ForAll( L, n -> SmallestRootInt( n ) = p ); end;

... which does what you want, e.g.:

gap> OnlyPowersOfp([8,32,128,1048576],2); true gap> OnlyPowersOfp([8,32,128,1048576],3); false gap> OnlyPowersOfp([8,9,128,1048576],2); false

If you have further questions about this I think that the gap-trouble list

is probably a better place for discussing these than the whole forum.

Hope this helps,

Stefan Kohl

> < [top]