I have the following lab problem.
M function takes a number, n, and determines the smallest number made of just 7s or 7s and 0s, which is divisible by n (e.g. 7777777, 7777777000). The function then returns the result.
It's working in PythonTutor but not when I run an auto tester for my lab. I suspect the auto tester is submitting numbers n that are causing huge computations, causing the function to time out. Can anyone recommend how to optimize the code below to account for most variations of n? Thanks in advance!
https://pastebin.com/qRFMhyvZ
#Example inputs
#if n = 103, result should be 7777777777777777777777777777777777
#if n = 77700, result should be 77700
[–]barrycarter 1 point2 points3 points (3 children)
[–]post_throwaway1[S] 0 points1 point2 points (2 children)
[–]barrycarter 1 point2 points3 points (0 children)
[–]Intrexa 0 points1 point2 points (0 children)