Weird Number
Basic Accuracy: 14.58% Submissions: 151 Points: 1

Given a number N check whether it is wierd or not. A number is weird if the sum of the proper divisors (divisors including 1 but not itself) of the number is greater than the number, but no subset of those divisors sums to the number itself.

Example 1:

Input: N = 70
Output: 1
Explanation: The smallest weird number 
is 70. Its proper divisors are 1, 2, 5, 
7, 10, 14, and 35; these sum to 74, but 
no subset of these sums to 70. 

Example 2:

Input: N = 12
Output: 0
Explanation: The number 12, for example,
is not weird, because the proper divisors 
of 12 are 1, 2, 3, 4, and 6, sum of 
divisors is 16; but there is a subset 
{2, 4, 6} with sum 12, i.e., 2+4+6 = 12.


Your Task:
You don't need to read or print anything. Your task is to complete the function is_weired() which takes n as input parameter and returns 1 if the number is weird number otherwise returns 0.


Expected Time Complexity: O(N)
Expected Space Complexity: O(1)


1 <= N <= 10000

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

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?


All Submissions

My Submissions:

Login to access your submissions.

Weird Number

Output Window