Ask Your Question

Revision history [back]

You can do this:

sage: k = 720
sage: sum(d for d in k.divisors() if d < 10)

See this tutorial.

You To extract the divisors less than 10, you can do this:

sage: k = 720
sage: sum(d for d in k.divisors() if d < 10)

See this tutorial.

The error you got is probably because of the following:

If you defined d as

sage: d = divisors(k)

Then d is a list. You can extract element number i of d as d[i], but you cannot do d(i) which would be "calling the function d with argument i". Sage tells you d is not "callable".

If you want to sum the first 10 divisors, do:

sage: sum(d[i] for i in range(10))

or

sage: sum(d[:10])