from pyspark import SparkContext sc = SparkContext.getOrCreate() print ("Spark context:",sc) def modInverse(a, prime) : a = a % prime for x in r