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
When you select an object in the Visual Studio Designer, the object's size, color, text, and other characteristics are displayed
harina [27]

Answer:

the main window if that`s not correct sorry

Explanation:

3 0
3 years ago
So a little back story. I'm pretty young won't say my age because I'll be judged. But I drink deer, vodlka, tequila, etc. I some
nikklg [1K]

Maybe were think you should do that if you really really want to date someone and then yeah go for it but if it’s gonna make you drink then I decide Maybe were think you should do that if you really really want to date someone then yeah go for it but if it’s gonna make you drink then I prefer you not date someone if it’s gonna make you drink because is not very good for someone young because I feel like you’re young girls or boy so that’s what my answer is and I hope it helped.

7 0
3 years ago
Read 2 more answers
Write a program that teaches arithmetic to a young child. The program tests addition and subtraction. In level 1, it tests only
Elenna [48]

Answer:

Explanation:

The following program is written in Java and creates three levels with the different set of randomly generated arithmetic problems. As the player goes getting more points they advance every 5 points to the next level.

import java.util.Random;

import java.util.Scanner;

class Main {

   private static Random random = new Random();

   private static Scanner in = new Scanner(System.in);

   static int points = 0;

   public static void main(String[] args) {

       while (true) {

           System.out.println(points);

           if (points < 5) {

               System.out.println("Starting Level 1");

               levelOne();

           } else if (points < 10) {

               System.out.println("Starting Level 2");

               levelTwo();

           } else if (points < 15) {

               System.out.println("Starting Level 3");

               levelThree();

           }

       }

   }

   public static boolean levelOne() {

       int numberOne = random.nextInt(10);

       int numberTwo = random.nextInt((10 - numberOne));

       int answer = numberOne + numberTwo;

       int count = 0;

       while (points < 5 && count < 2) {

           System.out.println("What is " + numberOne + " + " + numberTwo + "?: ");

           int userChoice = in.nextInt();

           if (userChoice == answer) {

               points += 1;

               levelOne();

           } else {

               count += 1;

           }

       }

       return false;

   }

   public static boolean levelTwo() {

       int numberOne = random.nextInt(10);

       int numberTwo = random.nextInt(10);

       int answer = numberOne + numberTwo;

       int count = 0;

       while (points < 10 && count < 2) {

           System.out.println("What is " + numberOne + " + " + numberTwo + "?: ");

           int userChoice = in.nextInt();

           if (userChoice == answer) {

               points += 1;

               levelTwo();

           } else {

               count += 1;

           }

       }

       return false;

   }

   public static boolean levelThree() {

       int numberOne = random.nextInt(10);

       int numberTwo = random.nextInt(10);

       int answer = numberOne - numberTwo;

       int count = 0;

       if (answer <= 0) {

           levelThree();

       }

       while (points < 15 && count < 2) {

           System.out.println("What is " + numberOne + " - " + numberTwo + "?: ");

           int userChoice = in.nextInt();

           if (userChoice == answer) {

               points += 1;

               levelThree();

           } else {

               count += 1;

           }

       }

       return false;

   }

}

3 0
3 years ago
MARK AS BRANLIEST!!!!
Oxana [17]

1. The reason for a photograph being a favorite is the creativity to capture nature in one single frame.

2. Photographs present the aesthetics and ability to view the world from a new perspective. Photographs' main benefit is they associate with the good memories the last for a lifetime

5 0
2 years ago
Read 2 more answers
The objective is to work with your partner to fix the HTML bugs so that none of the code is pink. In general, how do I change HT
Elan Coil [88]

Answer:

Click inspect then go to change color

Explanation:

there you go have a nice day!

8 0
3 years ago
Other questions:
  • When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions
    14·1 answer
  • The function of a start winding in a split-phase motor is to A. provide the starting torque. B. reduce the starting current. C.
    14·1 answer
  • A block level element begins on a new line and some space is usually added before and after it - True or False?
    13·1 answer
  • Write a program that prompts the user to input the number of quarters, dimes, and nickels. The program then outputs the total va
    10·1 answer
  • The formula A$7+$D7in cell was copied to cell H10.write the formula as it would appear in cell H10
    5·1 answer
  • An alteration threat violates information integrity. <br> a. True <br> b. False
    13·1 answer
  • What of the following is not a benefit of active listening
    8·2 answers
  • What do we call stores in a physical world?
    13·1 answer
  • What is difference between augmented reality and mixed reality?​
    11·1 answer
  • Two character strings may have many common substrings. Substrings are required to be contiguous in the original string. For exam
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!