Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Code example of Python Modulo Operator

# function is defined for finding out 
# the remainder of every number from 1 to n
def findRemainder(n, k):
    
  for i in range(1, n + 1):
    # rem will store the remainder 
    # when i is divided by k.
    rem = i % k  
    print(i, "mod", k, "=", rem, sep = " ")
  
# Driver code
if __name__ == "__main__" :
# inputs
  n = 10
  k = 7
# function calling
  findRemainder(n, k)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Code #Python #Modulo #Operator
ADD COMMENT
Topic
Name
5+5 =