answersLogoWhite

0


Best Answer

An easy way to calculate all the factors of whole numbers is to iterate from 1 to that number and check if the remainder is zero using the "%" operation.

def getFactors(num):

"""Return the factors of a whole number"""

factors = []

for i in range(1,num+1):

if num%i == 0:

factors.append(i)

return factors

Factoring negative numbers and zero simply requires a few more tweaks to the code.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you calculate factors of a number using python programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the meaning of ten high level programming language?

'ten' is a number; google for 'high level programming language'


In what programming language is substr used?

Java is the programming language where substr is used. Substr is a command that returns the characters in a string beginning at the specified location through the specified number of characters.


What is a perfect number in C programming?

A number sum of whose factors is equal to that number is known as perfect number. Eg. 6 Factors : 1,2,3 1+2+3=6 That's why it is a perfect number


Can you add a vairable with a number?

What, in a programming language? Sure. Anything that has a clearly defined value can be added.


What is orthogonality in a programming language?

In computer programming, orthogonality in a programming language means that a relatively small set of primitive constructs can be combined in a relatively small number of ways to build the control and data structures of the language. The term is most-frequently used regarding assembly instruction sets, as orthogonal instruction set.


How can you declare a number is prime or not in java programming?

Any prime number has only two factors which are itself and one whereas composite numbers all have more than two factors


Is 15 a factor of 240 Give reason?

To calculate factors using this tool, you will enter positive integers, because the calculator will only allow positive values, to calculate factors of a number. if you need to calculate negative numbers, you enter the positive value, get the factors and duplicate the answer yourself with all the give positive factors as negatives like as -5 and -6 as factors of number 30.


Where could you learn the programming language Cplusplus on the internet for free?

There are a number of websites that can teach C++ programming for no cost. Please see the related links for some sites.


What is the programming language you find easiest to understand?

This is largely a matter of personal opinion. You will likely get as many different answers as the number of computer programming languages that have ever existed.


What is c program to calculate product of all even numbers from entered number down to 1?

c is programming laungage


How do you calculate what whole number 100 has the most factors?

I wrote out all the factors of all the numbers from 1 to 100 and counted them.


What are some ways to compare 300 and 225?

calculate their ratiocalculate their differencecalculate the number of factorscalculate the number of prime factors.