Exercise 60
Write an algorithm in python which determines the list of all relative integers n <= 1000 such that:
n + 7 divides 3n5 + 19.
Solution
def solutionsList(n):
listSol = []
for i in range(1 , n):
if (3*i**5 +19)%(i + 7) == 0:
listSol.append(i)
return listSol
# Testing algorithm
print(solutionsList(1000))
# The output is : [4, 15, 22, 51, 72, 151, 312, 631, 862]
Younes Derfoufi
my-courses.net
my-courses.net