5
$\begingroup$

How to get following loop output using pure functions such as NestList?

For[i = 0; v = 0, i < 4 && v < 4, i++; v++,
Print[x^i + b^v]]

and the output is

2

b+x

b^2+x^2

b^3+x^3
$\endgroup$
  • $\begingroup$ Try MapThread[Function[{i, v}, Print[x^i + b^v]], {Range[0, 3], Range[0, 3]}] $\endgroup$ – Coolwater Jul 19 at 10:24
  • $\begingroup$ @CoolwaterThanks $\endgroup$ – Muhammad Ali Jul 19 at 10:33
8
$\begingroup$
#^Range[0, 3] & /@ (x + b)

x^# + b^# &@Range[0, 3]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.