1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
insens350 [35]
3 years ago
7

Write an application that displays every perfect number from 1 through 1,000. A perfect number is one that equals the sum of all

the numbers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it, and their sum is 6; however, 12 is not a perfect number because 1, 2, 3, 4, and 6 divide evenly into it, and their sum is greater than 12.
Computers and Technology
1 answer:
matrenka [14]3 years ago
5 0

Answer:

Written in Python

for num in range(1,1001):

    sum=0

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

         if num%j==0:

              sum = sum + j

                   if num == sum:

                        print(str(num)+" is a perfect number")

Explanation:

This line gets the range from 1 to 1000

for num in range(1,1001):

This line initializes sum to 0 for each number 1 to 1000

    sum=0

This line gets the divisor for each number 1 to 1000

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

This following if condition line checks for divisor of each number

<em>          if num%j==0: </em>

<em>               sum = sum + j </em>

The following if condition checks for perfect number

                   if num == sum:

                        print(str(num)+" is a perfect number")

You might be interested in
Bob has 2 candy bars he is fat what hapennes
Llana [10]

Answer:

he eats The candy Bar

Explanation:

I think cause As You told he is fat He might like sugary items

3 0
3 years ago
Read 2 more answers
4 types of system software
Elina [12.6K]
Operating systems.
Device drivers.
Middleware.
Utility software.
8 0
3 years ago
Read 2 more answers
What is one effective way for employees to keep their skill-sets current
natta225 [31]
Is it a multiple choice answer? if so would like to see the answers as there are TONS of effective ways and if i list one it may not be in that list you have if its multiple choice.
3 0
3 years ago
You are working on a ticket for a user who cannot access the Internet from their PC. After troubleshooting, how do you confirm t
ki77a [65]
Could be anything?
Maybe you get an email from them on their PC, which means they have internet
8 0
2 years ago
2.Consider the following algorithm and A is a 2-D array of size ???? × ????: int any_equal(int n, int A[][]) { int i, j, k, m; f
Elis [28]

Answer:

(a) What is the best case time complexity of the algorithm (assuming n > 1)?

Answer: O(1)

(b) What is the worst case time complexity of the algorithm?

Answer: O(n^4)

Explanation:

(a) In the best case, the if condition will be true, the program will only run once and return so complexity of the algorithm is O(1) .

(b) In the worst case, the program will run n^4 times so complexity of the algorithm is O(n^4).

5 0
3 years ago
Other questions:
  • Why are prepositions, conjunctions, and pronouns usually considered poor choices to use as key words?
    5·2 answers
  • How did mark watney survive the accident
    9·1 answer
  • The graph of which function has an axis of symmetry at x=-1/4​
    15·1 answer
  • It chapter 2 pennywise
    13·1 answer
  • Which are among the ways you can use bitlocker encryption? (choose all that apply?
    5·1 answer
  • Users of an access point share the transmission capacity of the access point. The throughput a user gets is called the ________.
    11·1 answer
  • Rachel typed two paragraphs and then realized she was in the wrong document. What steps should Rachel follow to quickly move the
    15·2 answers
  • A prefab allows you to reuse game objects over and over, while their component data remains intact. (1 point)
    14·1 answer
  • Denise found a volume of documents in the trash bin that contained individuals, names, social security numbers and years of birt
    14·1 answer
  • In _________, the process requests permission to access and modify variables shared with others. a) entry section b) critical se
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!