Skip to main content
1 of 5
garej
  • 5k
  • 2
  • 20
  • 44

Another approach is applicable if you already have some function, say s, and you do not the process that generated it.

s = Nest[1 + x^n (#) &, 1, 3] 

enter image description here

z = 1 + x^n (1 + x^n (1 + x^n)) 

Use ReplacePart with Map(/@)

ReplacePart[z, Position[z, n][[#]] -> Defer@# & /@ Range[3]] 

enter image description here

If you do not want x^1 drop Defer.

garej
  • 5k
  • 2
  • 20
  • 44