Question: Counters

okay, so I was asked this question

Consider the code below; it is a code that returns the integer factors of a given positive integer 
> ifact := proc (N::posint)
local n, p, f;
if N <= 3 then return n end if;
n := N; p := 2; f := NULL;
while p^2 <= n do
if irem(n, p) = 0 then n := iquo(n, p);
f := f, p else
p := nextprime(p)
end if
end do;
f, n
end proc;
> ifact(13589856000);
           2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 7, 7, 107
Modify this factorization code so as to group repeated factors together in some way. For example the above example would be displayed as a sequence of lists by: [2,8], [3,4], [5,3],[7,2],[107,1]; i.e., a prime factor, followed by its multiplicity (how many times it has been repeated).

okay, i was asked to do this problem. the concept is simple enough. someone suggested I use two arrays and do a counter. however, I have no idea how to set up a counter in maple. this class has been super tough for me considering i have no background and get 2 hours of lecture each week to learn this programming language.

would anyone know how to set up counters, or have an suggestions of what to do with this problem?
i was thinking i could do something that seperates the prime numbers and then does a nops command to get the multiplicity but i'm not sure how i would seperate the prime numbers to employ  the nops command.

Please Wait...