Write x^3 as x*x*x
If you want it in string form you can do it like this
x^3 /. Power -> (StringRiffle[#, "*"] &@ConstantArray[#1, #2] &)
"x * x * x"
This makes use of the fact that x^3 is internally written as Power[x,3]
.
Since you mention another language, here's a method using CForm
:
Unprotect[Power];
Power /: Format[x_Symbol^n_Integer?Positive, CForm] := SequenceForm @@ Riffle[
ConstantArray[x, n],
Format["*", OutputForm]
]
Protect[Power];
Example:
x^2+y^3 //CForm
x*x + y*y*y