SHARECHAT Coding Question β Solved
Task
Calculate the number of pairs of investment (i, j) such that the return is a perfect square.
Example 1
Assumptions
Input
N = 4
Output: 6
Approach
(1, 1), (1, 4), (2, 2), (3, 3), (4, 1), and (4, 4) are the possible pairs.
Square Investment
Bob and John both have N dollars each and want to invest some money in Jack.
They will invest amounts i, j (1 β€ i, j β€ N). Jack has promised them a return of i * j.
Bob and John will be happy if the return is a perfect square.
Function Description
Complete the function solution(). The function takes the following parameter and returns the solution:
- N: Represents the total amount.
Input Format for Custom Testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
- The first linecontains N, denoting the total amount.
Output Format
Return an integer representing the number of possible pairs.