Question: conversion into integer does not work for the output from ifactor

Hi,

I use Maple 2024 (X86 64 LINUX), and am trying to calculate the sum of the prime factors of integers.

My code is as simple as something like this:

SumPrimeFactors := proc(n)
    local f, L, p;
    f := ifactor(n);
    L := [op(f)];
    return add(convert(op(1, p), integer), p in L);  # Sum base primes
end proc:

However, the above code returns the following result when I set n = 360:

> SumPrimeFactors(360);
                                     5 +  (2) +  (3)

while what I had expected is just an integer, 10 (= 5+2+3).
It seems the operation convert(op(1, p), integer) is not working properly, and "(2)" is recognized as an expression, not an integer, even after the convert operation.

I have no idea how I should rectiy it.
I would be glad if someone gives me a way to get it solved.
Thank you very much.

Please Wait...