`{"id":"05f28e7f-e5cb-4279-9d8f-e471cd6bbf1f","name":"Recurring Sequence In A Fraction","description":"1. You are given two numbers which represent the numerator and denominator of a fraction.\r\n2. You have to convert this fraction into a decimal.\r\n3. If the decimals are repeating recursively, then you have to put the recurring sequence inside a bracket. ","inputFormat":"A number N1 representing the numerator of a fraction.\r\nA number N2 representing the denominator of a fraction.","outputFormat":"A String representing a decimal number. ","constraints":"1 &lt;= N1,N2 &lt;= 2000 ","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\nstring solution(int num, int den) {\n //write your code here\n}\n\n\nint main()\n{\n int num, den;\n cin >> num;\n cin >> den;\n\n cout << solution(num, den);\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String solution(int num, int den) {\r\n // write your code here\r\n \r\n return null;\r\n }\r\n \r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint num = scn.nextInt();\r\n\t\tint den = scn.nextInt();\r\n\t\tSystem.out.println(solution(num , den));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"8\r\n4","sampleOutput":"2\r\n","questionVideo":"https://www.youtube.com/embed/2cRS9dNa780?end=520","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"d72bf49c-fa3b-453d-a626-a03f3522f898","name":"Recurring Sequence In A Fraction","slug":"recurring-sequence-in-a-fraction","type":1}],"next":{"id":"aef4c197-2997-4a68-8aff-b21f799fe024","name":"Recurring Sequence In A Fraction MCQ","type":0,"slug":"recurring-sequence-in-a-fraction-mcq"},"prev":{"id":"bee33bf8-8cf8-4ec1-a411-57f8e6a44fff","name":"Pairs With Equal Sum","type":3,"slug":"pairs-with-equal-sum"}}}`

# Recurring Sequence In A Fraction

1. You are given two numbers which represent the numerator and denominator of a fraction. 2. You have to convert this fraction into a decimal. 3. If the decimals are repeating recursively, then you have to put the recurring sequence inside a bracket.

`{"id":"05f28e7f-e5cb-4279-9d8f-e471cd6bbf1f","name":"Recurring Sequence In A Fraction","description":"1. You are given two numbers which represent the numerator and denominator of a fraction.\r\n2. You have to convert this fraction into a decimal.\r\n3. If the decimals are repeating recursively, then you have to put the recurring sequence inside a bracket. ","inputFormat":"A number N1 representing the numerator of a fraction.\r\nA number N2 representing the denominator of a fraction.","outputFormat":"A String representing a decimal number. ","constraints":"1 &lt;= N1,N2 &lt;= 2000 ","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\nstring solution(int num, int den) {\n //write your code here\n}\n\n\nint main()\n{\n int num, den;\n cin >> num;\n cin >> den;\n\n cout << solution(num, den);\n return 0;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static String solution(int num, int den) {\r\n // write your code here\r\n \r\n return null;\r\n }\r\n \r\n public static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint num = scn.nextInt();\r\n\t\tint den = scn.nextInt();\r\n\t\tSystem.out.println(solution(num , den));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"8\r\n4","sampleOutput":"2\r\n","questionVideo":"https://www.youtube.com/embed/2cRS9dNa780?end=520","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"d72bf49c-fa3b-453d-a626-a03f3522f898","name":"Recurring Sequence In A Fraction","slug":"recurring-sequence-in-a-fraction","type":1}],"next":{"id":"aef4c197-2997-4a68-8aff-b21f799fe024","name":"Recurring Sequence In A Fraction MCQ","type":0,"slug":"recurring-sequence-in-a-fraction-mcq"},"prev":{"id":"bee33bf8-8cf8-4ec1-a411-57f8e6a44fff","name":"Pairs With Equal Sum","type":3,"slug":"pairs-with-equal-sum"}}}`

Editor

# Recurring Sequence In A Fraction

hard

1. You are given two numbers which represent the numerator and denominator of a fraction. 2. You have to convert this fraction into a decimal. 3. If the decimals are repeating recursively, then you have to put the recurring sequence inside a bracket.

## Constraints

1 <= N1,N2 <= 2000

## Format

### Input

A number N1 representing the numerator of a fraction. A number N2 representing the denominator of a fraction.

### Output

A String representing a decimal number.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}8 4```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}2 ```

Question Video

Discussions

Show Discussion

Related Resources