Write an algorithm and pseudocode to compute f(x)=1+x+x^2+x^3+....+x^n
Algorithm
Start
Declare variable n
Declare variable x
Get n from the user
Get x from the user
Declare variable sum=1
for i = 1 to n step 1
Find sum = sum + x^i
next
Display sum
End
Pseudocode
Start
Set n = 0
Set x = 0
Get n from the user
Get x from the user
Set sum = 1
for i = 1 to n
sum = sum + x^i
Display sum
End
Comments