> < ^ From:

> < ^ Subject:

Dear GAP Forum,

Saad Belawi asked:

saadchina@maktoob.com said:

> 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

A reasonably efficient and simple solution is

IsPowerOfP := function(n,p)

return n mod p = 0 and IsPrimePowerInt(p);

end;

Then for instance, set p and then do:

Filtered(L, n->IsPowerOfP(n,p));

will give you the list of all powers of p in L.

Steve

-- Steve Linton School of Computer Science & Centre for Interdisciplinary Research in Computational Algebra University of St Andrews Tel +44 (1334) 463269 http://www.dcs.st-and.ac.uk/~sal Fax +44 (1334) 463278

> < [top]