#!/usr/bin/env python
num_str = raw_input('Enter a number: ')
num_num = int(num_str)
non_fac_list = range(1, num_num+1)
print "BEFORE: ", repr(non_fac_list)
i = 0
while i < len(non_fac_list):
if num_num % non_fac_list[i] == 0:
del non_fac_list[i]
i = i + 1
print "AFTER: ", repr(non_fac_list)
What kind of program is it? Is there an error in this program?
python
It's like going to a shaman's house and testing a shaman. Let's ask at least what you're curious about.
I think we're going to pick only non-minus numbers out of the natural numbers we've entered.
There's something wrong, as you'll see after a few runs.
while i < len(non_fac_list):
if num_num % non_fac_list[i] == 0:
del non_fac_list[i]
continue
i = i + 1
After removing mineral water, do not increase i. Currently, the number after the mineral water is not tested, but is to be moved on.
© 2024 OneMinuteCode. All rights reserved.