Divisible by 7
Easy Accuracy: 65.5% Submissions: 2276 Points: 2

Given an n-digit large number in form of string, check whether it is divisible by 7 or not. Print 1 if divisible by 7, otherwise 0.

Example 1:

Input: num = "8955795758"
Output: 1
Explanation: 8955795758 is divisible
by 7.

Example 2:

Input: num = "1000"
Output: 0
Explanation: 1000 is not divisible
by 7.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function isdivisible7​() which takes the string num as inputs and returns the answer.

Expected Time Complexity: O(|num|)
Expected Auxiliary Space: O(1)

1 ≤ |num| ≤ 105

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.

Divisible by 7

Output Window