Skip to content

Instantly share code, notes, and snippets.

@ivalexandru
Created January 20, 2018 13:25
Show Gist options
  • Save ivalexandru/372b8000e1511de6cfc1c1c7f2836a09 to your computer and use it in GitHub Desktop.
Save ivalexandru/372b8000e1511de6cfc1c1c7f2836a09 to your computer and use it in GitHub Desktop.
"""For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)
R: There were a number of tricky things with this exercise.
First, the type conversions between input strings and integers for the range()
function need to be carefully output.
Second, the arguments to range() had to be carefully constructed to cover
all the possible numbers. Third, the condition in the if statement had to be correct as well."""
num = int(input("Baga nr: "))
print(type(num)) # e int pt ca l-am fortat
#daca nu fortam, ar fi fost str si nu mergea
listRange = list(range(1,num+1)) #merge si daca nu pun list
divisorList = [] #lista goala
print(type(divisorList))
for number in listRange:
if num % number == 0:
divisorList.append(number)
#ia nr pe care il introduc eu, incearca sa il imparta la numerele din range, pe rand
#daca se imparte la nr X cu rest zero, atunci acel nr X e appendat/adaugat la divisorList
print(divisorList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment