# The number 1 evaluates inside HoldForm sometimes

If I run the following code:

Do[
Print["*** ", HoldForm[x] /. x -> a, " ***"];
Print["Replace: ", (HoldForm[x] /. x -> a) /. {n1 -> 1, n2 -> 2, n3 -> 3}];
Print["FullForm: ", FullForm[a]];
, {a, {n1 n2, -n1 n2, n1 n2 n3}}
]


I get

    *** n1 n2 ***
Replace: 1 x 2
FullForm: Times[n1,n2]
*** -n1 n2 ***
Replace: -2
FullForm: Times[-1,n1,n2]
*** n1 n2 n3 ***
Replace: 2 x 3
FullForm: Times[n1,n2,n3]


I kind of understand what is going on, but I would like the output in the second case to be -1 x 2 and in the third case 1 x 2 x 3. How do I do that?

• Because $1$ is an identity element for multiplication, it gets removed at once in Times[]. (Similarly, $0$ is quickly removed in Plus[].) Perhaps you want something like Inactivate[Times[1, 2, 3], Times]? – J. M.'s technical difficulties May 14 at 15:31
• Thank you. Unfortunately, I need to block 1, not Times, and Inactivate[1] is just the same as 1. However, your solution inspired me to find a solution of my own, which I will post now. – Mattia Landoni May 14 at 19:26

{n1 -> HoldForm[1], n2 -> 2, n3 -> 3}

If later one wants the expression evaluated, it will be enough to use HoldForm[] twice.