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
umka2103 [35]
3 years ago
8

Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorith

m should report the values 1, 2, 3, 4, 6, and 12
Computers and Technology
1 answer:
Nadya [2.5K]3 years ago
3 0
As I say to every one requesting programming help on these forums. If you don't specify a language, then it just means you'll have to translate the answer that is given to you, to a different language. Here's what you want in Java:


<span>import java.util.InputMismatchException<span>;
</span>import java.util.Scanner<span>;
</span>
public class Test {
    public static void main(String[] args) {
        int number = numInput()<span>;
</span>        printFactors(Math.abs(number))<span>;
</span>    }

    private static int numInput() {
        Scanner sc = new Scanner(System.in)<span>;
</span>
        System.out.print("Enter number: ")<span>;
</span>
        int input<span>;
</span>        while (true) {
            try {
                input = sc.nextInt()<span>;
</span><span>                break;
</span>            } catch (InputMismatchException e) {
                System.out.println("Not a number.")<span>;
</span>            }
        }

        return input<span>;
</span>    }

    private static void printFactors(int number) {
        if (number == 0) {
            System.out.println("Infinite factors.")<span>;
</span>        } else {
            for (int i = 1; i <= number; i++) {
                for (int j = 1; j <= number; j++) {
                    if (i * j == number) {
                        System.out.print(i + ", ")<span>;
</span>                    }
                }
            }
        }
    }
}</span>
You might be interested in
Francisco is becoming a dad for the first time. He feels relatively clueless about all things involving parenting and is looking
sergij07 [2.7K]

The source which would most likely fit Francisco's needs is: B. The US Children’s Bureau.

<h3>What is the US Children’s Bureau?</h3>

The US Children’s Bureau can be defined as a federal agency of the United States of America which was founded under the United States Department of Health and Human Services by William Howard Taft in 1912.

The main purpose of the US Children’s Bureau is to improve the lives of children and families through special programs that are designed and developed to:

  • Prevent or reduce child abuse.
  • Foster child care.
  • Enhance child adoption.

In conclusion, the US Children’s Bureau would help Francisco learn about the basics such as installing a car seat and childproofing his home.

Read more on US Children’s Bureau here: brainly.com/question/6043069

5 0
3 years ago
Angela wants to give her press release an attractive and cohesive appearance. How can she quickly format her press release so it
I am Lyosha [343]

Answer:

Press release tools on websites

Explanation:

There are several tools on websites that provide quick press release. It is possible to directly select the style from several choices. Each style has own fonts and colors however, it is possible to change them.  

Step by step;

Angela may enter the website that provides press release

Then can select a theme with fonts and colors

Then she can put her work

It is ready to publish

8 0
4 years ago
Which file extension takes less storage space?
anyanavicka [17]

I believe the answer would be the JPEG file extension.

4 0
3 years ago
Read 2 more answers
Susan is creating a spreadsheet, and she needs to enter the months of the year in column A. Susan should _____.
AysviL [449]
Enter January in A1 hold mouse in bottom right hand corner of cell. Hold mouse button down and drag the mouse. Excel will populate the months of the year
3 0
3 years ago
Read 2 more answers
Stores of data that are so vast that conventional database management systems cannot handle them, and very sophisticated analysi
Colt1911 [192]
Maybe an international database, where all nations are invited to contribute information, THEREFORE, there would be a vast amount of data.
5 0
3 years ago
Other questions:
  • A student is searching through a large box of unused cables and connectors in the classroom. The student finds a ribbon with con
    14·1 answer
  • All of the following are good reasons to attend a cummunity college except
    10·2 answers
  • When advising a customer on the purchase of a new power supply, you should explain that if the power supply runs at peak perform
    9·1 answer
  • During college jesse spent four semesters studying abroad in other parts of the world how could jesses time abroad benefit his e
    5·2 answers
  • What is the problem with the code snippet below? public class Test { public static void main(String[] args) { System.out.println
    6·1 answer
  • What is obtained after processing data?​
    8·1 answer
  • Which function works best when you need to remove an element at a pacific index and a list
    15·1 answer
  • Data owners ensure that only the access that is needed to perform day-to-day operations is granted and that duties are separated
    10·1 answer
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
  • <img src="https://tex.z-dn.net/?f=%20%5Csf%20%7B%20%5Cfcolorbox%7Bgold%7D%7Bg%7D%7B%20Define%20malware%7D%7D%20" id="TexFormula1
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!