Given a number as string(n) , find the remainder of the number when it is divided by 7
Example 1:
Input:
5
Output:
5
 
Example 2:
Input:
8
Output:
1
 
Your Task: 
You only need to complete the function remainderwith7() that takes string n as parameter and returns an integer which denotes the remainder of the number when its divided by 7
 
Constraints:
1<=length of n <=105

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: class Solution:

    #your task is to complete this function

    #Function should return the required answer

    #You are not allowed to convert string to integer

    def remainderWith7(self, str):

        #Code here

Solutions:
class Solution:

	def remainderWith7(self, str):
		return int(str) % 7


class Solution:

	def remainderWith7(self, str):
		n = int(str)
		a = n % 7
		return a


class Solution:

	def remainderWith7(self, str):
		s = int(str)
		if s < 7:
			return str
		else:
			s = s % 7
		return s


class Solution:

	def remainderWith7(self, str):
		c = int(str)
		if c < 7:
			return c
		else:
			return c % 7


class Solution:

	def remainderWith7(self, str):
		s = int(str)
		rem = s % 7
		return rem


class Solution:

	def remainderWith7(self, s):
		s1 = int(s)
		s2 = s1 % 7
		return s2


class Solution:

	def remainderWith7(self, str):
		me = int(str)
		if me < 7:
			return str
		else:
			me = me % 7
		return me


class Solution:

	def remainderWith7(self, str):
		rem = 0
		for ch in str:
			num = rem * 10 + (ord(ch) - ord('0'))
			rem = num % 7
		return rem


class Solution:

	def remainderWith7(self, str):
		num = int(str)
		ans = num % 7
		return ans


class Solution:

	def remainderWith7(self, str):
		a = int(str)
		b = a % 7
		c = int(b)
		return c


class Solution:

	def remainderWith7(self, str):
		a = int(str)
		if a < 7:
			return a
		else:
			return a % 7


class Solution:

	def remainderWith7(self, str):
		m = int(str)
		if m < 7:
			return str
		else:
			m = m % 7
		return m


class Solution:

	def remainderWith7(self, n):
		n = int(n)
		return n % 7


class Solution:

	def remainderWith7(self, s):
		return int(s) % 7


class Solution:

	def remainderWith7(self, str):
		num = int(str)
		while num > 0:
			rem = num % 7
			return rem


class Solution:

	def remainderWith7(self, str):
		if int(str) % 7 == 0:
			return int(str) % 7
		else:
			return int(str) % 7


class Solution:

	def remainderWith7(self, str):
		n = int(str)
		if n < 7:
			return n
		return n % 7


class Solution:

	def remainderWith7(self, str):
		series = [1, 3, 2, -1, -3, -2]
		j = 0
		i = len(str) - 1
		res = 0
		while i >= 0:
			res += int(str[i]) * series[j]
			j = (j + 1) % 6
			i -= 1
			res = res % 7
		return res


class Solution:

	def remainderWith7(self, s):
		if int(s) < 7:
			return s
		else:
			a = int(s) % 7
			return a


class Solution:

	def remainderWith7(self, s):
		if int(s) < 7:
			return s
		elif int(s) == 7:
			return str(0)
		else:
			a = int(s) % 7
			return a


class Solution:

	def remainderWith7(self, str):
		n = int(str)
		if n < 7:
			return n
		elif n == 7:
			return 0
		else:
			output = n % 7
			return output


class Solution:

	def remainderWith7(self, str):
		num = int(str)
		if num < 7:
			return str
		else:
			num = num % 7
		return num


class Solution:

	def remainderWith7(self, str):
		g = int(str)
		v = g % 7
		return v


class Solution:

	def remainderWith7(self, str):
		x = int(str)
		n = x % 7
		return n


class Solution:

	def remainderWith7(self, str):
		res = 0
		for i in str:
			res = (res * 10 + int(i)) % 7
		return res