Question

Write a program called factor.py that uses at least one loop to print out “Multiple of...

Write a program called factor.py that uses at least one loop to print out “Multiple of x!” for each element x that is a multiple of the factors: 5, 7, or 13 between zero and 100. If a number is a multiple of more than one factor, for example 35 is a multiple of both 5 and 7, print out “Multiple of 5 and 7!”. If all three are factors, then print out “Multiple of 5 and 7 and 13!”.

CODE IS PYTHON 3

Homework Answers

Answer #1
for i in range(101):
    if(i%5==0 and i%7==0 and i%13==0):
        print("Multiple of 5 and 7 and 13!")
    elif(i%5==0 and i%7==0):
        print("Multiple of 5 and 7!")
    elif (i % 5 == 0 and i % 13 == 0):
        print("Multiple of 5 and 13!")
    elif (i % 7 == 0 and i % 13 == 0):
        print("Multiple of 7 and 13!")
    elif(i%5==0):
        print("Multiple of 5!")
    elif (i % 7 == 0):
        print("Multiple of 7!")
    elif (i % 13 == 0):
        print("Multiple of 13!")

Multiple of 5 and 7 and 13!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 13!
Multiple of 7!
Multiple of 5!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 13!
Multiple of 7!
Multiple of 5!
Multiple of 5 and 7!
Multiple of 13!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 13!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 7!
Multiple of 5 and 13!
Multiple of 5 and 7!
Multiple of 5!
Multiple of 7!
Multiple of 13!
Multiple of 5!
Multiple of 7!
Multiple of 5!
Multiple of 5!
Multiple of 7 and 13!
Multiple of 5!
Multiple of 7!
Multiple of 5!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
use python Write a program that uses a for loop to display all prime numbers within...
use python Write a program that uses a for loop to display all prime numbers within the range [500, 800] (hint: prime numbers are numbers that have only 2 factors: 1 and themselves. You can use a loop function to check if a number has a factor other than 1 or itself using % operation)
Write a Java program called Decision that includes a while loop to prompt the user to...
Write a Java program called Decision that includes a while loop to prompt the user to enter 5 marks using the JOptionPane statement and a System. Out statement to output a message inside the loop highlighting a pass mark >= 50 and <= 100. Any other mark will output a messaging stating it’s a fail. Example of the expected output is as follows:
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
Problem #5: This one is a challenge!! Write a program that will print out a representation...
Problem #5: This one is a challenge!! Write a program that will print out a representation of the University of Washington “W” using a character that a user provides.
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
python code Write the function definition for a function which accepts one value from the main...
python code Write the function definition for a function which accepts one value from the main program and prints three times the number that is sent to it. For example, if the program sent 8, the function would print 24.
For each equation, write a brief program to compute and print eight steps of Newton's method...
For each equation, write a brief program to compute and print eight steps of Newton's method for finding a positive root (Preferably in Matlab or Python). a. x=2sinx b. x^3=sinx+7 c. sinx=1-x d. x^5+x^2=1+7x^3 for x>=2
Write a program in Python to declare two empty lists one is for name and one...
Write a program in Python to declare two empty lists one is for name and one for salaries. Within the for loop ask for employees name and their salaries and append them into the list accordingly. Find out the total salary using accumulation concept within the for loop. Output : Both of the lists with their items and the total salary.
Write a program in python that prints the count of all prime numbers between A and...
Write a program in python that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = The 5 digit unique number you had picked at the beginning of the semester B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2,...