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
Cerrena [4.2K]
3 years ago
14

Write a script that calculates the common factors between 8 and 24. To find a common factor, you can use the modulo operator (%)

to check whether a number can be evenly divided into both numbers.
Computers and Technology
1 answer:
AnnyKZ [126]3 years ago
8 0

Answer:

  1. common = []
  2. num1 = 8
  3. num2 = 24
  4. for i in range(1, num1 + 1):
  5.    if(num1 % i == 0 and num2 % i == 0):
  6.        common.append(i)
  7. print(common)

Explanation:

The solution is written in Python 3.

Firstly create a common list to hold a list of the common factor between 8 and 24 (Line 1).

Create two variables num1, and num2 and set 8 and 24 as their values, respectively (Line 3 - 4).

Create a for loop to traverse through the number from 1 to 8 and use modulus operator to check if num1 and num2 are divisible by current i value. If so the remainder of both num1%i and num2%i  will be zero and the if block will run to append the current i value to common list (Line 6-8).

After the loop, print the common list and we shall get [1, 2, 4, 8]

You might be interested in
In which conditions, a trial balance does not tally?
Nostrana [21]

Answer:

A trial balance will not balance if both sides do not equal, and the reason has to be explored and corrected.

Explanation:

The debit side and the credit side must balance, meaning the value of the debits should equal the value of the credit

4 0
2 years ago
Lil fun question : burgers or pizza??
Margarita [4]
Pizza. . . . . . . . . . .
6 0
2 years ago
Read 2 more answers
Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit f
Artemon [7]

Answer:

The representation of 100.0 in the floating-point representation is computed as follows: First convert the given number 100.0 in the binary form. 10010 = 11001002 the binary representation.

Explanation:

3 0
2 years ago
Pleasee help meeeeeeeeee I’m stuckk!!!!
Anit [1.1K]

Answer: Charles Babbage

4 0
2 years ago
Read 2 more answers
3. Which property is used to select full Row of data grid view
Tju [1.3M]

Answer:

I think a is correct answer.

4 0
3 years ago
Other questions:
  • Does anybody know how to use these showers?
    11·2 answers
  • Compare the current in two lightbulbs wired in a series circuit
    11·1 answer
  • You have just driven to the Hewlett-Packard site in Corvallis to field-interview a programmer. You sit down in a conference room
    6·1 answer
  • The algorithm ADDN implements N-bit fixed-width binary addition for non-negative integers and ignores overflows. For example, AD
    13·1 answer
  • Variables set equal to patterns are said to be:_______.
    7·1 answer
  • What is virtual reality?
    10·1 answer
  • Compressing a file is also called
    9·2 answers
  • Write a recursive function sumAll that accepts an integer argument and returns the sum of all the integers from 1 up to the numb
    10·1 answer
  • Since the rules cannot address all circumstances, the Code includes a conceptual framework approach for members to use to evalua
    8·1 answer
  • Explain the integer and float datatypes with example.<br><br>​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!