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
Please help me!
BaLLatris [955]

Answer:

Choose what you think based on this.

Explanation:

with a for loop:

>>> students = 3

>>> for student in range(students):

>>> print(student)

would output

>>> 0

>>> 1

>>> 2

with a while loop now:

>>> students = 3

>>> student = 0

>>> while student < students:

>>> student = student + 1

>>> print(student)

the for loop is more compact than the while loop. But there may be some times when a you cant do a for loop. The first question is more than likely definite but I don't know the second answer.

8 0
3 years ago
Read 2 more answers
_____ is the process of bypassing the built-in limitations and protections of a mobile device. Group of answer choices D. Slicin
katrin2010 [14]

Answer:

C

Explanation:

Jailbreaking is the process of bypassing the built-in limitations and protections of a mobile device

7 0
2 years ago
Which of the following is considered both an input and output peripheral?
larisa [96]
Keyboard
Explaination: it is period
8 0
3 years ago
A student has a ten-year-old desktop computer that she only uses for word processing, but she would like to start using it to pl
wariber [46]

Answer:

She should buy a new one or buy a Gaming PC to upgrade the setup.

Explanation:

6 0
3 years ago
____ formatting is automatically updated if you change data in the worksheet.
andriy [413]

Answer:

<u>Conditional</u> formatting is automatically updated if you change data in the worksheet.

Explanation:

Conditional formatting can be described as a tool that allows users to format a particular cell or a group of cells. The formatting also changes for any data being changed in the sheet.

A particular cell can have up to three format conditions and these conditions will be applied automatically to any changes entered in the cell. The conditional formatting also has the option to highlight the important cells.

4 0
3 years ago
Other questions:
  • ________ hackers break into systems for non-malicious reasons such as to test system security vulnerabilities. black-hat gray-ha
    10·1 answer
  • What economic measure is at the highest level since the Great Depression?
    12·1 answer
  • Team A found 342 errors during the software engineering process prior to release. Team B found 184 errors. What additional measu
    12·1 answer
  • Linda is the education manager for a national coding service company. Once a month she holds a videoconference with all her codi
    14·1 answer
  • Write a program called DeliveryCharges for the package delivery service in Exercise 4. The program should again use an array tha
    9·1 answer
  • 3.3 Code Practice: Question 1
    15·1 answer
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    9·1 answer
  • Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the
    8·1 answer
  • Select the best answer from the drop-down menu. ________ networks use cables connected directly to the computer. Signals sent in
    11·1 answer
  • How do I create a simple percentage function to gather a score for a quiz in PHP?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!