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
Being aware of and understanding why potential buyers on a web site do not complete their purchases requires the expertise of __
TiliK225 [7]
<span>a web analyst and usability expert</span>
8 0
3 years ago
Read 2 more answers
At the beginning of Section 5.2, it is stated that multiprogramming and multiprocessing present the same problems, with respect
QveST [7]

Answer:

By definition, <u>multiprocessing</u> refers to the processing of multiple processes at the same time by multiple CPUs.

By definition, <u>multiprogramming</u> keeps programs in main memory at the same time and execute them concurrently utilizing a single CPU doing a context switch.

The first difference is that multiprocessing uses multiple CPUs and multiprogramming to utilize context switch to do concurrency in one CPU. Another difference is that multiprocessing is more expensive but more efficient than multiprogramming due that it allows parallel processing.

6 0
3 years ago
HELPPPPPPP!!!!!!!!!
Andrei [34K]
The compression ratio is 20:1 please mark me brainliest
3 0
3 years ago
Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int d
xeze [42]

Answer:

void showSquare(int param){

}

Explanation:

In C++ programing language, this is how a function prototype is defined.

The function's return type (In this case Void)

The function's name (showSquare in this case)

The function's argument list (A single integer parameter in this case)

In the open and closing braces following we can define the function's before for example we may want the function to display the square of the integer parameter; then a complete program to accomplish this in C++ will go like this:

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>void showSquare(int param);</em>

<em>int main()</em>

<em>{</em>

<em>    showSquare(5);</em>

<em>    return 0;</em>

<em>}</em>

<em>void showSquare(int param){</em>

<em>int square = param*param;</em>

<em>cout<<"The Square of the number is:"<<endl;</em>

<em>cout<<square;</em>

<em>}</em>

8 0
4 years ago
What are the common causes of signal loss in fiber optic cable connectors
timurjin [86]
Bending, twisting, or the overall age of the cable, or other stuff like that.
8 0
3 years ago
Other questions:
  • What does the “Rooms” feature of FriendFeed do? Allows users with common interest to share their views and streams Allows users
    10·1 answer
  • An expression that has correctly paired delimiters is called a(n)
    6·1 answer
  • "Common knowledge" must always be credited or else it is considered plagiarism?<br> True<br> Fales
    5·1 answer
  • python An acronym is a word formed from the initial letters of words in a set phrase. Write a program whose input is a phrase an
    14·2 answers
  • Your desktop, Internet Explorer®, and the Media Player can be started from this area on most computers.
    10·2 answers
  • A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never
    7·1 answer
  • Which software documentation guideline did the IEEE establish?
    10·1 answer
  • How many different textile items would you find at a festival? (please list 5 items)
    7·1 answer
  • The project team is creating detailed documents to guide the team. What phase of the project life cycle are they in?
    6·1 answer
  • leon started a project to design and create a new video game for the animation studio where he develops graphics and animations
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!