Array class question

Ok, so I have this function mystery,

int mystery(int n) {

if ( n == 0 || n == 1 || n == 2) return n ;
return (mystery(n-1) + mystery(n-2) + mystery(n-3)) ;
}


What is the value of mystery(20)?
How many addition operations are carried out when calculating mystery(20)?
How many invocations of mystery() in order to calculate mystery(20)?

Any help would be greatly appreciated.
1. A big one.
2. Many.
3. Many.

For 1) just compile the function and call it with 20 to find out- or do the additions manually.
2) Count them or let your program do it
3) Count them or let your program do it
4) No problem with helping with homeworks, but please at least do enough so that we get the image you at least attempted to do it on your own.
Topic archived. No new replies allowed.