Answer in Java Tim while preparing for his CAT exam, was studying the topic Number Systems. He encountered a loving da question: Given a number N, find the number of pairs (cy) where both x and y are...


Answer in Java



Tim while preparing for his CAT exam, was studying the topic Number Systems. He encountered a loving da question:


Given a number N, find the number of pairs (cy) where both x and y are less than N and Highent Common Factor(HCF) of x and y is 1.



You have to solve the question for him.


Note: 0 can be included within the pairs



Input Specification:


Input: The number N from which the pairs (x,y) should be obtained



Output Specification:


Return the total number of pairs



Example 1:



input1: 4


Output: 9



Explanation:


The pairs can be (1,0) ,(0,1) (1,1) (1,2) (2,1) (0, 3) (3,1) (2,3) (0,2)


So, a total of 9 pairs



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here