Expensive Dinner (Small)

Each friend is happy only when the running total is a multiple of their number, so find how the arrival order changes the number of waiter calls for N friends.

Medium7Number theoryMathGreedyNo attempts yetTime limit5sMemory limit512 MB

Problem

Tonight your friends are all going to the same restaurant for dinner. They are quick with arithmetic and every one of them is picky: friend number aa (numbering starts at 1) is happy only when the running total cost of the meal is a positive integer divisible by aa, and is unhappy otherwise.

Your friends walk into the restaurant one at a time. The moment somebody walks in, if that person is unhappy then the group calls a waiter right away.

While at least one person inside the restaurant is unhappy, one of those unhappy people buys the cheapest item that makes them happy, so the total rises to the next multiple of that person's number. This repeats until nobody inside the restaurant is unhappy, and then the waiter leaves. The restaurant sells food at every integer price, so any amount can be spent exactly.

Before anybody has bought anything the total is 0, and 0 is not a positive integer, so the first person to walk in is always unhappy.

Your friends may walk in in any order. After a waiter has been called, when more than one person is unhappy, any one of them may be the next to buy something. Those choices change how many times the group calls a waiter.

You own the restaurant and your waiters are tired. Given the number of friends NN, compute the difference between the largest possible number of waiter calls and the smallest possible number of waiter calls.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains one integer NN, the number of friends.

Limits

  • 1T1001 \le T \le 100
  • 1N10001 \le N \le 1000

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting at 1 and yy is the answer for that test case.

Hint

Take N=3N = 3. Suppose the friends walk in in the order 1, 2, 3. Friend 1 walks in, is unhappy, calls a waiter, and buys an item of price 1, so the total is 1. Now nobody is unhappy. Friend 2 walks in next, is unhappy, calls a waiter, and buys an item of price 1, so the total is 2. Again nobody is unhappy. Friend 3 walks in last, is unhappy, calls a waiter, and buys an item of price 1, so the total is 3. Now friend 2 is unhappy and buys an item of price 1, making the total 4, and then friend 3 is unhappy and buys an item of price 2, making the total 6. Nobody is unhappy any more and the waiter was called three times.

Now suppose the order is 3, 1, 2. Friend 3 walks in, is unhappy, calls a waiter, and buys an item of price 3, so the total is 3. Friend 1 walks in next and nobody is unhappy. Friend 2 walks in last, is unhappy, calls a waiter, and buys an item of price 1, so the total is 4. Friend 3 is then unhappy and buys an item of price 2, making the total 6. Nobody is unhappy and the waiter was called two times. The answer for N=3N = 3 is 1.