Answer the question
In order to leave comments, you need to log in
Why is the program not producing results?
Write a program that searches among the integers
belonging to the numerical interval [312614; 312651], numbers that
have exactly six different natural divisors
here is my code, but it does not give a result
for i in range(312614, 312652):
dels = []
for y in range(1, (i//2)+1):
if i%y==0:
dels.append(y)
if len(dels)==6:
print(i, dels)
else:
print('no')
Answer the question
In order to leave comments, you need to log in
A very strange question. And what number, in your opinion, from the range [312614; 312651], has exactly six different natural divisors? Given that you have written a program in such a way that you also consider "1" a divisor.
1 is a natural divisor of any natural number, the number itself is also a natural divisor of itself.
Your mistake is that you check up to the root of the number and skip divisors that are greater than this value. You can do that, but then you should consider that each divisor has a pair (divider and value/divider), except for the case when divider == value/divider.
312628: 1, 2, 4, 78157, 156314, 312628
312651: 1, 3, 9, 34739, 104217, 312651
Try adding one line to your code and see why the program didn't produce a result.
for i in range(312614, 312652):
dels = []
for y in range(1, (i//2)+1):
if i%y==0:
dels.append(y)
print(i, len(dels), dels)
if len(dels)==6:
print(i, dels)
else:
print('no')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question