Problem · Math

Find Reciprocal

Learn this problem
MediumDTCCOA

Problem statement

Given an integer, find its reciprocal. The reciprocal will end in infinitely recurring digits. Print the recurrence twice with a space between the first and second repetition.

For example, if N = 8, its reciprocal is 1/8 = 0.12500000..., so print 0.1250 0. If N = 9, its reciprocal is 1/9 = 0.111111..., so print 0.1 1.

Function

findReciprocal(N: int) → String

Complete the function findReciprocal in the editor.

findReciprocal has the following parameter:

  1. int N: the integer to find the reciprocal of

Returns

String: the recurrence of the reciprocal printed twice with a space between the repetitions

Examples

Example 1

N = 8return = "0.1250 0"

The reciprocal of 8 is 1/8 = 0.12500000..., so the output is 0.1250 0.

Example 2

N = 9return = "0.1 1"

The reciprocal of 9 is 1/9 = 0.111111..., so the output is 0.1 1.

Constraints

2 ≤ N ≤ 10^5

drafts saved locally
public String findReciprocal(int N) {
  // write your code here
}
N8
expected"0.1250 0"
checking account