Write an algorithm which will evaluate:
Pn(x) = (N + 1)xn + N x n - 1 + ... + 2x + 1
I am trying to write pseudocode to evaluate the above. I am trying to do using a while loop and without using arrays.
So far I have something like this:
P:= 0
R:= 0
N:= 9
SUM:=0
WHILE (N >=0 )
BEGIN
R:= N MOD 10
BEGIN
P:= P*X
SUM:=SUM +R
N:= N-R
N:= N / 10
But it is not evaluating correctly. Any guidance would be great!
If I understand correctly, you need something like this:
SUM:=0
POWER:=1
I:=0
WHILE I <= N
SUM:=SUM+(I+1)*POWER
POWER:=POWER*X
I:=I+1
END WHILE