Geeksforgeeks

Error

Given a number N. Check if it is a Kaprekar number or not.

**Note:- **A Kaprekar number is a number whose square when divided into two parts the sum of those parts is equal to the original number and none of the parts has value 0. Now given a number, your task is to check if it is Kaprekar number or not.

**Example 1:**

**Input:**
N=45
**Output:**
1
**Explanation:**
45*45=2025. Now, 20+25=45.
Thus, 45 is a kaprekar number.

**Example 2:**

**Input:**
N=20
**Output:**
0
**Explanation:**
20*20=400.There is no way to divide
400 into two parts such that their sum is equal
to 20.So, 20 is not a kaprekar number.

**Your Task:**

You don't need to read input or print anything.Your Task is to complete the function **isKaprekar()** which takes the number N as input parameter and returns 1 if N is a kaprekar number.Otherwise, it returns 0.

**Expected Time Complexity:**O(LogN)

**Expected Auxillary Space:**O(1)

**Constraints:**

1<=N<=10^{4}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Kaprekar Number

...