Jump to content

HELP: Scala sequence function

yamileon

so im doing this scala sequence problem and cant figure it out at all 

im able to get the code working but the math not so much 

 

edit: even how to read the sequence An =(-1).... would help 

 

Question in image 

 

def series(n:Double):Double={
  def tail(acc:Double,n:Double):Double={
    if(n < 1)acc
    else {
      tail( acc + ( math.pow(-1,n) * ( (5 + (5 + (n-1) ) ) + math.pow(-1,n-1) ) * (3 + (3 + (n - 2)) ) ), n - 1 )
    }
  }
  tail(0,n)
}

series(3)

what i have so far

Capture.PNG

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×