Jump to content

beginner question: need help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
pokjin

pokjin

    Newbie

  • Members
  • Pip
  • 1 posts
im new to python, im trying to find how many divisors a number has. but in that process find the one with the greatest divisors. im complete lost because i can only get it to find the on integer i input. any help would be great. well heres the code i came up with so far.


    a = input("enter an integer greater than 1:  ")

    if a < 2:

        print "Please enter an integer greater than 1."


    def divisorGenerator(n):

        for i in range(1, n-1):

            if n%i==0:

                yield i

        yield n

     


    for i in divisorGenerator(a):

        print i,



i have to make it look like this

    enter an integer greater than 1: 15

    2: 2 divisors

    3: 2 divisors

    4: 3 divisors


    4 has the maximum number of divisors with 4


#2
Chessur

Chessur

    Newbie

  • Members
  • PipPip
  • 29 posts
Hssssssssssssssss