title: Subtraction count down to zero game pattern with recursion in c++
body: <p>Using recursion I have to make an AI for a game where computer will choose from 4 , 3 or 1 and subtract it from a given number between 1 to 99 inclusive. This game will be played between the AI and a human. However, AI cannot pick any random number from 4,3 or 1. It must always pick values which will help it win the game. Also, when the number is something like 2 , AI or human cannot pick 4 or 3 as it is bigger than 2 so they have to pick 1. Also assume that the AI is player 2 and human is always player 1.</p>
  
  <p>For example : If the starting number is n = 7, then player 1 picks 1 and n = 6 , then computer picks 4 and new n = 2. Player 1 will choose 1 and n = 1. Then AI will choose 1 and n = 0. Hence AI won the game.</p>
  
  <p>What I have thought about this problem so far:</p>
  
  <p>I know different numbers until 6 which should be chosen by AI (from 4, 3 or 1) to win the game. </p>
  
  <blockquote>
    <p>For example: When  n =1, choose 1 
    n = 2, choose 1 ;
    n = 3, choose 3 ;
    n =4, choose 4 ;
    n = 5, choose 3 ;
    n = 6, choose 4 ;</p>
  </blockquote>
  
  <p>But I am unable to find a general algorithm which can be applied to all numbers from 1 to 99 to win the game. 
  I want to know and understand how to get  a general recursive equation and recursive algorithm like the one in Fibonacci series for a function recursion : </p>
  
  <blockquote>
    <p>Fibonacci(n - 1) + Fibonacci(n - 2)</p>
  </blockquote>
  
  <p>to choose number between 4 3 or 1 by AI to win the game.</p>
  
  <p>I am not experienced at recursion so please try to explain algorithm in detail.</p>