Divisibility by 999
Easy Accuracy: 60.5% Submissions: 200 Points: 2

You are given a large number N in the form of a string, you have to check whether it is divisible by 999 without dividing or finding modulo of number by 999.

 

Example 1-

Input:
N = 1998
Output:
Divisible

 

Example 2 -

Input:
N = 999999999
Output:
Not divisible

 

Your Task :
Complete the function isDivisible999() that receives a string N denoting number and returns true if the n is divisible by 999 and flse otherwise. The driver code itself prints "Divisible" if the returned value is true and returns "Non Divisible" if returned value is false.

 

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

 

Constraints:
1<=|N|<=103

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.

Editorial

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

Yes

All Submissions

My Submissions:

Login to access your submissions.

Divisibility by 999

Output Window