Ruud H.G. van Tol on Sun, 19 Dec 2021 15:24:30 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

factorint_as_string()



sf() = my(v=Vec(factorint(n)~)); if(!#v, v=Vec([1;1])); for(i=1, #v, v[i]=if(v[i][2]>1, strjoin(v[i],"^"), v[i][1])); strjoin(["(", strjoin(v," * "), ")"])

Example:

? sf(3087)
%527 = "(3^2 * 7^3)"

-- Ruud