def main(): longestPeriod = 1 number = 0 for i in range(950, 1000): thisLength = numberwork.lengthOfRDR( i ) if thisLength > longestPeriod: longestPeriod = thisLength number = i print( number, "has the longest reciprocal decimal repetend at", \ longestPeriod )
Where 0.1(6) means 0.1666666..., and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle. Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part. """ import sys import time import numberwork def main(): longestPeriod = 1 number = 0 for i in range(950, 1000): thisLength = numberwork.lengthOfRDR( i ) if thisLength > longestPeriod: longestPeriod = thisLength number = i print( number, "has the longest reciprocal decimal repetend at", \ longestPeriod ) if __name__ == "__main__": if len( sys.argv ) > 1: t0 = time.time() print( numberwork.lengthOfRDR( int( sys.argv[1] ) ) ) print( "Execution time: " + str( time.time() - t0 ) ) else: main()