Question

Write a python code to determine the factors of a positive number N entered by the...

Write a python code to determine the factors of a positive number N entered by the user and their sum. For instance, if N=10 its factors are: 1, 2, 5, 10. Hint: You can use the mod or % operator to compute the remainder of an integer division. Test the program with N=100.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# sample N value
N = 100

# looping from 1 to N
for i in range(1, N+1):
  
# if N is divisible by i, printing i
if N % i == 0:
print(i, end = " ")
  
# Hit the thumbs up if you are fine with the answer. Happy Learning!

Add a comment
Know the answer?
Add Answer to:
Write a python code to determine the factors of a positive number N entered by the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please solve it by Python 3 Write a program that asks the user for a positive...

    Please solve it by Python 3 Write a program that asks the user for a positive integer limit and prints a table to visualize all factors of each integer ranging from 1 to limit. A factor i of a number n is an integer which divides n evenly (i.e. without remainder). For example, 4 and 5 are factors of 20, but 6 is not. Each row represents an integer between 1 and 20. The first row represents the number 1,...

  • Exercise 9.2 Write a Python program that collects from the user a single integer. Have the...

    Exercise 9.2 Write a Python program that collects from the user a single integer. Have the program print “EVEN” if the integer is divisible by 2, and “ODD” if the integer is not divisible by two. [Use the % operator to compute the two’s modulus (remainder of division by two)] Exercise 9.3 Write a Python program that collects from the user two integers. Have the program print “Yes” if the two integers are BOTH greater than 10. Do nothing if...

  • Write the roman.cpp implementation file that converts a number entered in Roman numerals to a positive...

    Write the roman.cpp implementation file that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanType. An object of type romanType should do the following: Step a: Store the number as a Roman numeral. Step b: Convert and store the number as a positive integer. Step c: Print the number as a Roman numeral or positive integer as requested by the user. Step d: Test your program using the following...

  • Write in Java Write code which checks validity of a 3-digit positive integer entered by the...

    Write in Java Write code which checks validity of a 3-digit positive integer entered by the user. The number is considered valid (true) if the sum of the first two digits is less than the last. Otherwise it is invalid (false).

  • Problem 1: Write a program that reads a positive float number and displays the previous and...

    Problem 1: Write a program that reads a positive float number and displays the previous and next integers. Sample Run: Enter a float: 3.5 The previous and next integers are 3 and 4. Problem 2: Write a program that reads two integers and displays their sum, difference, product, and the result of their division. Sample Run: Enter two integers: 8 5 Sum: 8, Difference: 3, Product: 40, Division: 1.6 Problem 3: Write a program that reads a three-digit integer from...

  • In Python, write a program that asks the user for a positive integer number. If the...

    In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686

  • A perfect number is a positive integer that is equal to the sum of its (proper)...

    A perfect number is a positive integer that is equal to the sum of its (proper) positive divisors, including 1 but excluding itself. A divisor of a number is one which divides the number evenly (i.e., without a remainder). For example, consider number 6. Its divisors are 1, 2, 3, and 6. Since we do not include number itself, we only have 1, 2, and 3. Because the sum of these divisors of 6 is 6, i.e., 1 + 2...

  • Python My ITlab: 1. Write some code that repeatedly reads a value into the variable n...

    Python My ITlab: 1. Write some code that repeatedly reads a value into the variable n until a number between 1 and 10 (inclusive) has been entered. 2. Write some code that repeatedly reads a value from standard input into the variable response until at last a Y or y or N or n has been entered. 3.Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, each on a separate...

  • Write a Python program to print all Perfect numbers between 1 to n. (Use any loop...

    Write a Python program to print all Perfect numbers between 1 to n. (Use any loop you want) Perfect number is a positive integer which is equal to the sum of its proper positive divisors. Proper divisors of 6 are 1, 2, 3. Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect number. *** proper divisor means the remainder will be 0 when divided by that number. Sample Input: n =...

  • NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. NO PYTHON...

    NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. NO PYTHON 8 CODE PLEASE.! it's PEP/8 the assembler, nothing to do with python. Write a program in Pep/8 or Pep/9 object code that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT