[GAP Forum] First GAP program

Haidar Youness haidaryouness at ymail.com
Tue Nov 19 19:35:23 GMT 2013


Hi... My name is Jay and I'm new to this forum. And I'm writing my first GAP code; Basically I'm trying to find the number of a times a number "p" can be divided by a prime number "n" such that "p|n" is an integer. The program seems pretty trivial but every time it executes it keeps giving me zero regardless of the input. If somebody can just tell me where i went wrong with my code. Thank you. The code is as folows:


PowerofpDividingn := function(p,n)

       local x, count, ans;
       count :=0;

       for x in [1..p] do
            ans := p/n;
            if ans in Integers then
               count := count  + 1;
            fi;
            p := ans; 
       od;
    return count;
end;


More information about the Forum mailing list