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
Leave a comment