How does Python determine the Abundant Number?

Source: Internet
Author: User

How does Python determine the Abundant Number?

This article describes how to use Python to determine the Abundant Number. Share it with you for your reference. The details are as follows:

Abundant Number is a special natural number. The sum of all positive values except itself is greater than itself.

Introduction see Baidu Encyclopedia: http://baike.baidu.com/view/1596350.htm

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

# Checks if a number is abundant or not

# An abundant number is the number of which sum

# Factors (including itself) is greater than twice the number

Def abundant (n ):

Sum_factors = 0

For I in range (1, n + 1 ):

If n % I = 0:

# Finds out the factors

F = I

Sum_factors + = f

If sum_factors> 2 * n:

# Condition for abundant number

Print "This is an Abundant Number! "

Else:

Print "This is not an Abundant Number! "

I hope this article will help you with Python programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.