Indian National Olympiad in Informatics, 2003

IARCS home > OLYMPIAD > Archives

INOI-2003, Sample questions

Problem 3: Recurring decimals

Write a program that reads an integer n as input and prints out the decimal representation of 1/n. If 1/n is a recurring decimal, print out two copies of the recurring portion. You may assume that n is between 1 and 10000.

Here are some sample inputs and outputs for this problem:

  • Input: 2
    Output: 0.500
  • Input: 3
    Output: 0.33
  • Input: 5
    Output: 0.200
  • Input: 7
    Output: 0.142857142857
  • Input: 11
    Output: 0.0909


Copyright (c) IARCS 2003-2018;   Last Updated: 11 Apr, 2003