Halloween Sale

  • + 0 comments

    static int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy

     // Return the number of games you can buy
          int numberOfGames = 0;
    
            int i = p;
            for ( i= p; i <= s; i += p)
            {
                numberOfGames++;
                // d = p <= m ? m : d;
    
                 p = p < m || (p - d) <=0 || (p-d)<m ? m : p - d;
    
            }
             return numberOfGames;
    
    }