Answer the question
In order to leave comments, you need to log in
USE Informatics 25 task (python). What is wrong in my program?
Task:
Write a program that searches among the integers belonging to the numerical interval [312614; 312651], numbers that have exactly six different natural divisors. For each number found, write these six divisors in six adjacent columns on the screen on a new line. Divisors in a string must be in ascending order.
For example, in the range [12; 15] exactly six different natural divisors have the number 12, so for this range the output on the screen should contain the following values:
1 2 3 4 6 12
--------------------- -------------------------------------------------- -------------------------------------------------- ----------------------------
Wrote the following program:
a = 312614
b = 312651
for i in range (a, b):
ds = []
for d in range (1, i):
if (i % d == 0):
ds.append(d)
if len(ds) > 6:
break
if (len(ds) == 6):
print (ds[0], ds[1], ds[2], ds[3], ds[4], ds[5])
Answer the question
In order to leave comments, you need to log in
if len(ds) is GREATER than six, abort
if len(ds) > 6:
break
if (len(ds) == 6):
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question