Under construction

Still being built. Things may change

Sierpiński circumference

Time limit2sMemory limit1024 MB

Summary
Each iteration multiplies the number of triangles by 3 and the side length by 1/2; report the number of digits of the total perimeter 3*(3/2)^n.
Level

Medium4 of 10

Topics
Math, Number theory, Implementation
Solved
No attempts yet

Problem

Polish mathematician Wacław Sierpiński (1882-1969) described the 2D geometric figure known as the Sierpiński triangle as part of his work on set theory in 1915. The triangle, which is really an infinite collection of points, can be constructed by the following algorithm:

  1. The initial shape is a solid triangle.
  2. Shrink the current shape to half its dimensions (both height and width), and make two more copies of it (giving three copies total).
  3. Arrange the three copies so that each touches the two others at their corners. Set the current shape to be the union of these three.
  4. Repeat from step 2.

Here is an illustration of the first few iterations:

 
iteration01234

As the iterations go to infinity, this process creates an infinite number of connected points. However, consider the case of a finite number of iterations. If the initial triangle has a circumference of 3, what is the sum of the circumferences of all (black) triangles at a given iteration? Write a program to find out not the exact circumference, but the number of decimal digits required to represent its integer portion. That is, find the number of decimal digits required to represent the largest integer that is at most as large as the circumference.

Input

Each test case is a line containing a non-negative integer 0 ≤ n ≤ 10,000 indicating the number of iterations.

Output

For each case, display the case number followed by the number of decimal digits required to represent the integer portion of the circumference for the given number of iterations. Follow the format of the sample output.

Examples1

  1. Example 1

    Input
    0
    1
    5
    10
    100
    
    Expected output
    Case 1: 1
    Case 2: 1
    Case 3: 2
    Case 4: 3
    Case 5: 19