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
choli [55]
3 years ago
13

Write a function, factors, that takes an integer n, and returns a list of values that are the positive divisors of n. Note: 0 is

not a divisor of any integer, 1 divides every number, and n divides itself.
Computers and Technology
1 answer:
Helen [10]3 years ago
4 0

Answer:

public int[] factors(int n)

{

int arr[]=new int[n];

int count=0;

for(int i=1;i<=n;i++)

if(n%i==0)

{

arr[count]=i;

count++;

}

return arr;

}

Explanation:

Factors are the numbers you multiply to get another number. For instance, factors of 15 are 3 and 5, because 3×5 = 15.

In the program , we have an array of length N to store the factors.

Since we don't know the number of factors of N, so we have taken size of upper bound N to store list of factors in the array arr.

Within the loop the number gets divide by Integers from 1 to that number until result is 0. If it is 0, that number is stored in array.

You might be interested in
In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle obj
MakcuM [25]

The program based on the information given is illustrated below.

<h3>What is a program?</h3>

A computer program simply means a sequence of instructions in a programming language that is created for a computer to execute.

It should be noted that computer programs are among the component of software.

The program to create two rectangle objects and get their area and perimeter is depicted:

// Rectangle.cpp

using namespace std;

class Rectangle

{

public:

// Declare public methods here

void setLength(double);

void setWidth(double);

double getLength();

double getWidth();

double calculateArea();

double calculatePerimeter();

private:

// Create length and width here

double length, width;

};

void Rectangle::setLength(double len)

{

length = len;

}

void Rectangle::setWidth(double wid)

{

// write setWidth here

width = wid;

}

double Rectangle::getLength()

{

// write getLength here

return length;

}

double Rectangle::getWidth()

{

// write getWidth here

return width;

}

double Rectangle::calculateArea()

{

// write calculateArea here

return length*width;

}

double Rectangle::calculatePerimeter()

{

// write calculatePerimeter here

return 2*(length+width);

}

// This program uses the programmer-defined Rectangle class.

#include "Rectangle.cpp"

#include <iostream>

using namespace std;

int main()

{

Rectangle rectangle1;

Rectangle rectangle2;

rectangle1.setLength(10.0);

rectangle1.setWidth(5.0);

rectangle2.setLength(7.0);

rectangle2.setWidth(3.0);

cout << "Perimeter of rectangle1 is " << rectangle1.calculatePerimeter() << endl;

cout << "Area of rectangle1 is " << rectangle1.calculateArea() << endl;

cout << "Perimeter of rectangle2 is " << rectangle2.calculatePerimeter() << endl;

cout << "Area of rectangle2 is " << rectangle2.calculateArea() << endl;

return 0;

}

/*

output:

The perimeter of rectangle1 is 30

The area of rectangle1 is 50

The Perimeter of rectangle2 is 20

The area of rectangle2 is 21

*/

Learn more about program on:

brainly.com/question/1538272

#SPJ1

8 0
2 years ago
A Flash Translation Layer translates user data to a format that can be written on the NVM. tracks which physical block contains
masha68 [24]

Answer:

tracks which physical block contains only valid pages.

Explanation:

Flash translation layer or FTL is a system made up of software and hardware that manages solid-state drive or SSD operations. It implements data concurrency techniques like striping, interleaving, and pipelining to generate a high throughput. It also performs logical to physical addressing amongst other functionalities.

The FTL also tracks which physical block in the memory that contains only valid pages by performing a bad block management process, isolating and discarding the blocks with no valid pages

7 0
3 years ago
Which of the following is a part of a DML statement? a. CREATE b. ALTER c. DROP d. SELECT. SE_LECT
Margaret [11]

d. SELECT

"SELECT" is a part of a DML statement.

What is DML?

DML, or Data Manipulation Language, is a subset of database operations used to insert, delete, and update data. A DML is frequently a sublanguage of a larger language, such as SQL; DML includes some of the language's operators. Because some users can perform both read and write selection, selecting read-only data is closely related to and sometimes considered a component of a DML.

Structured Query Language, or SQL, is a popular data manipulation language that is used to retrieve and manipulate data in a relational database. SQL allows you to perform database operations as well as create databases. SQL performs the required tasks by using specific commands such as Create, Drop, Insert, and so on.

To know more about DML, visit: brainly.com/question/25757965

#SPJ4

8 0
1 year ago
Features present in most GUIs include _____.
atroni [7]
Forms, Icons, Menus, Windows
3 0
4 years ago
Read 2 more answers
To give text an outline, you can use which command?
Sindrei [870]

Answer:

To show all text in an outline. Position the cursor the and then press

Alt + Shift + A

Explanation:

8 0
3 years ago
Other questions:
  • Which of the following are advantages of cloud computing?
    6·2 answers
  • Complete the sentence.
    7·1 answer
  • Ben chang noticed that his store was lagging in sales . He realized that his staff was not experienced enough . As the store man
    13·2 answers
  • On computer X, a nonpipelined instruction execution would require 12 ns. A pipelined implementation uses 6 equal-length stages o
    9·1 answer
  • You can upgrade a cpu by adding registers and cache memory to it. <br> a. True <br> b. False
    7·1 answer
  • When you write a C# program that stores a value in a variable, you are using temporary storage; the value you store is lost when
    12·1 answer
  • Which character goes at the end of a line of code that starts with if?
    8·1 answer
  • Which of the following is an example of hypertext pattern reading?
    13·1 answer
  • Firestick optimizing system storage and applications
    14·1 answer
  • : Describe the type of gameplay seen during early video games (ex. Spacewar!, Pong).
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!