#include <iostream>

#include <cmath>

using namespace std;

#define FORN(i,a,b) for (int i=a;i<=b;i++)

const int MAX=1000000;

 

pair<int,int> getPair(double n)

{

      int a,b;

      int c=0;

      double mingap=0.999;    //just under 1

      FORN(i,1,MAX)

      {

            int jlow=(int)(i/(n+mingap));

            int jhigh=(int) (i/(n-mingap));

            jlow=jlow<1?1:jlow;

            jhigh=jhigh>MAX?MAX:jhigh;

            FORN(j,jlow,jhigh)

            {    

                  double temp=abs((double)i/j-n);

                  if (temp<mingap)

                  {

                        mingap=temp;

                        a=i;

                        b=j;

                        break;

                  }

            }

      }

      return make_pair(a,b);

}

 

int main()

{

 

      int casenum=1;

     

      double n;

      while(cin>>n && n!=0)

      {

            pair<int,int> p=getPair(n);

            if (casenum>1) cout<<endl;

            cout<<"Case "<<casenum++<<" is best approximated as "<<p.first<<"/"<<p.second<<endl;

      }

 

      return 0;

}