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
Write a program that asks a user to enter a date in month day year format (for example 10 12 2016) and displays the day of the w
AleksAgata [21]

Answer and Explanation:

Using javascript:

function dayof_theweek(){

var TodayDate = window. prompt("enter today's date in the format 'year, month, day' ");

var Datenow=new date(TodayDate);

var Dayofweek=Datenow.getday();

var Days=["monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];

if(Dayofweek==indexOf(Days[Dayofweek]))

{

document.createTextnode(Days[Dayofweek]);

}

}

The program above uses a date object which uses the method getday to get the day of the week(get day returns an integer from 0 to 6).we then use a comparison operator == to test the condition that returned value Dayoftheweek is same with the index of the array Days and then print to a html document. The program may need improvements such as the fact that errors may arise when proper input isn't given, and therefore must be handled.

8 0
3 years ago
Describe two steps to find if photos can be legally used
Neporo4naja [7]

Answer:

  1. Check if the image is protected by copyright
  2. Check if the picture has a watermark

Explanation:

Hope it helps

5 0
2 years ago
Complete the firstMiddleLast() function to return a new string with the first, middle, and last character from string. If string
morpeh [17]

public static void main()

{

String s = Console.ReadLine();

int len = s.length();

Char startletter = s[0];

Char endletter = s[len-1];

string midletter = ‘’;

if(len % 2 ==0)

midletter = s[len/2] + s[(len/2) +1]

else

midletter = s[len/2];

Console.WriteLine(startletter + midletter + endletter);

}

Here the logic is that, startletter is obtained using the index ‘0’, the last letter is obtained by calculating the “length of the string” and subtract 1 to get the “last index” of the given string.

Middle letter is calculated by first finding whether the given string length is “odd or even” and based on that index(es) are identified.

4 0
3 years ago
List and describe the five moral dimensions that are involved in political, social, and ethical issues. Which do you think will
lukranit [14]

The five moral dimensions are:

  • Information rights and obligations.
  • Property rights and obligations
  • System quality.
  • Quality of life,
  • Accountability and control.

I see that Quality of life is most difficult for society to deal with as there ae lots of rich and poor people and the government have not been able to bridge the gap between them.

<h3>What are the morals about?</h3>

The five main moral dimensions that are known to be written above are said to be tied together in regards to ethical, social, and political issues that are seen in any information society.

Therefore, The five moral dimensions are:

  • Information rights and obligations.
  • Property rights and obligations
  • System quality.
  • Quality of life,
  • Accountability and control.

Learn more about moral dimensions from

brainly.com/question/15130761

#SPJ1

3 0
2 years ago
A computer is a multipurpose device that accepts input processes data and produces output all according to a series of stored
yulyashka [42]
According to a series of stored procedures 
8 0
3 years ago
Other questions:
  • Which signal types are represented by a continuous waveform?
    10·1 answer
  • The drone intercepts at 1256 hour. what time do they plane to take control of the drone
    11·1 answer
  • What are some ways to change column width? Check all that apply.
    13·2 answers
  • Write a program that prompts the user to enter the center and a point on the circle. The program should then output the circle’s
    9·1 answer
  • Shipments of compact digital cameras dropped by 42% due to the industry being unable to adjust to changes in the ________. a. ec
    11·1 answer
  • What did Aristotle teach?
    6·2 answers
  • 1
    13·1 answer
  • Who is the host in super monkey ball?
    14·1 answer
  • What are the two extra registers that the fetch decode execute cycle uses to communicate with memory outside of the chip?
    9·1 answer
  • To embed a Flash file, you must specify a location for the embedded video clip with the ____ parameter and a size for the clip u
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!