Computers and Technology
Computers and Technology, 27.11.2019 19:31, luckylady

Write a function called factors of number that takes as input a positive integer and returns the factors of the positive integer as an array. for example, if the integer is 6, the output is an array consisting of the values [1 2 3 6]. test your function on the following numbers: 26, 64, 97 and 187
1 and the number itself are always factors.
2. to find other factors, check up to the floor of the squareroot of the number. for example, if the number is 10, floor (squareroot 10) = 3.
a. 10 mod 2 equals 0. that means 2 and 5 (which is 10/2) are factors. in this case, it is ok to dynamically grow your array.
b. 10 mod 3 equals 1, which means 3 is not a factor. since we check up to 3, this completes the function and we return [1 10 2 5] as the factors of 10 (order is not important).

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 11:00, la200564
How should you specify box sizes on a web page if you want the boxes to vary according to the font size of the text they contain? a. in pixels b. in inches c. as percentages d. in em units
Answers: 2
image
Computers and Technology, 24.06.2019 04:30, andrespacheco5888
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
image
Computers and Technology, 24.06.2019 13:00, sparkyjones02
Which best describes the condition under which the unicode output is the same as plain text ?
Answers: 1
image
Computers and Technology, 24.06.2019 20:00, Cookie320
Write c++programs for the following problem: let the user enter two numbers and display which is greater. !
Answers: 1
Do you know the correct answer?
Write a function called factors of number that takes as input a positive integer and returns the fac...

Questions in other subjects: