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
Difference between volatile and non volatile memory
slega [8]
<span>Volatile memory requires electricity or some kind of current to store information, and nonvolatile memory does not.</span>
6 0
3 years ago
Read 2 more answers
A communications medium that carries a large amount of data at a fast speed is called
babymother [125]
Either Firewire, or an ethernet cable.
7 0
3 years ago
Convert the following numbers from decimal to binary, assuming unsigned binary representation:________.
kumpel [21]

Answer:

Binary representations of following are:

A) 35 = 100011

B) 3 = 11

C) 27 = 11011

D) 16 = 10000

Explanation:

The method to generate the binary number from a decimal is :

Keep on dividing the number by 2 and keep on tracking the remainder

And the quotient is again divided and remainder is tracked so that the number is completely divided.

And then write the binary digits from bottom to top.

Please have a look at the method in below examples:

A) 35

\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 35 & 1 \\  2 & 17 & 1 \\   2 & 8 & 0  \\ 2 & 4 & 0  \\ 2 & 2 & 0   \\ 2 & 1 & 1\end{tabular}\end{center}

Writing the remainder from bottom to top.

So, binary number is 100011

B) 3

\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 3 & 1 \\  2 & 1 & 1 \\  \end{tabular}\end{center}

Writing the remainder from bottom to top.

So, binary equivalent is 11.

C) 27

\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 27 & 1 \\  2 & 13 & 1 \\   2 & 6 & 0  \\ 2 & 3 & 1  \\ 2 & 1 & 1   \end{tabular}\end{center}

Writing the remainder from bottom to top.

So, binary equivalent is 11011.

D) 16

\begin{center}\begin{tabular}{ c c c }Number & Quotient & Remainder\\ 2 & 16 & 0 \\  2 & 8 & 0 \\   2 & 4 & 0  \\ 2 & 2 & 0  \\ 2 & 1 & 1   \\\end{tabular}\end{center}

Writing the remainder from bottom to top.

So, binary equivalent is 10000.

Answers are:

Binary representations of following are:

A) 35 = <em>100011</em>

B) 3 = <em>11</em>

C) 27 = <em>11011</em>

D) 16 = <em>10000</em>

8 0
3 years ago
Write a program that allows the user to continuously input the value n until a negative number is entered
Paul [167]

Answer:

Written in C++

Explanation:

#include <iostream>

using namespace std;

int main()

{

int n;

while(true)

{

cin>>n;

if(n>=0)

continue;

break;

}

return 0;

}

3 0
2 years ago
Two friends can share 100 songs from their Bluetooth enabled mobile devices
Umnica [9.8K]

Answer:

A

Explanation:

If they are connected via bluetooth, you can share unlimited amounts of anything.

6 0
2 years ago
Other questions:
  • 3k means about 3 thousand bytes. how would you express two hundred million bytes?
    8·1 answer
  • Which statement is true about parity in RAM?
    11·1 answer
  • In Word, tables can be styled much like text can.<br> True<br> False
    6·1 answer
  • When people talk about "the media," they often mean:?
    6·1 answer
  • What part of the meat help you identify the less tender cuts​
    13·1 answer
  • 31
    10·1 answer
  • Please help fast
    5·1 answer
  • In this exercise we will practice using loops to handle collections/containers. Your job is to write a program that asks the use
    6·1 answer
  • In which program structure does the processor verify the mentioned condition only after executing the dependent statements once?
    8·2 answers
  • What is smarta Art ? ​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!