Question

Print all the "almost prime" numbers between A and B if A>B (python) input: 15 17...

Print all the "almost prime" numbers between A and B if A>B (python)

input:

15

17

output

15

16

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a=int(input('Enter the first number :'))

b=int(input('Enter the second number :'))

if(a>b):

print('Wrong input.First number should be less than second number')

else:

print("All prime numbers are :")

for i in range(a,b):

flag=0

for j in range(2,i):

if(i%j==0):

flag=1

break

if(flag==0):

print(i)

new* 1 a=int(input(Enter the first number :)) 2 b=int(input(Enter the second number :)) 3 if(a>b): 4 print(Wrong input.F

e TAB Enter the first number : 4 Enter the second number :20 All prime numbers are : 5 7 11 13 17 19 [Program finished]

If you have any questions comment down and please? upvote thanks...

Add a comment
Know the answer?
Add Answer to:
Print all the "almost prime" numbers between A and B if A>B (python) input: 15 17...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program to print all the prime numbers below a certain given number. A...

    Write a java program to print all the prime numbers below a certain given number. A prime number is defined as a number that can only be divided by 1 and itself. Requirements: 1. Accept the upper limit from the user as an integer. 2. You can assume the user input will be positive and smaller than INT MAX 3. Go from 1 to the number. If you happen to find a number that is prime, print it. The input...

  • PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random...

    PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random integer numbers between 1 and 100. Then, print out the numbers between the two randomly generated ones using a while loop. The output is shown below. Output: a) start:4, end:14 4 5 6 7 8 9 10 11 12 13 14 b) start:15, end:20 15 16 17 18 19 20

  • Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the...

    Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the console (inclusive). The identified prime numbers must be stored in an array . The inputted number should be between 0 and 1000 (inclusive). array is large enough to o Make sure your hold all the prim e numbers. Dynamic memory allocation is not required for this assignment, so you can have unused space in your array Make sure you can handle the cases of...

  • Write a Python program to print all Perfect numbers between 1 to n. (Use any loop...

    Write a Python program to print all Perfect numbers between 1 to n. (Use any loop you want) Perfect number is a positive integer which is equal to the sum of its proper positive divisors. Proper divisors of 6 are 1, 2, 3. Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect number. *** proper divisor means the remainder will be 0 when divided by that number. Sample Input: n =...

  • I must create a Loop in C++ that will print all prime numbers less than the...

    I must create a Loop in C++ that will print all prime numbers less than the number entertered by the user. 1. Accept the upper limit from the user (as an integer). (5 points) 2. Make sure the number is positive. If it is not, terminate the program. (5 points). 3. Go from 1 to the number. If you happen to find a number that is prime, print it. (35 points) example: Enter the upper limit: 25 The prime numbers...

  • The prime factorization of a number is the unique list of prime numbers that, when multiplied,...

    The prime factorization of a number is the unique list of prime numbers that, when multiplied, gives the number. For example, the prime factorization of 60 is 2 ∗ 2 ∗ 3 ∗ 5. In this problem you must write code to recursively find and return the prime factorization of the given number. You must print these in ascending sorted order with spaces in between. For example, if your input is: 120 then you should print the following output: 2...

  • Write a Python function that creates and returns a list of prime numbers between 2 and...

    Write a Python function that creates and returns a list of prime numbers between 2 and N, inclusive, sorted in increasing order. A prime number is a number that is divisible only by 1 and itself. This function takes in an integer and returns a list of integers.

  • Write a MIPS Assembly program to accept two numbers A and B from the user. Print...

    Write a MIPS Assembly program to accept two numbers A and B from the user. Print all the prime numbers between A and B. Also, check if A and B are prime. If no prime number exits print the string "No prime number between numbers A and B"

  • The prime factorization of a number is the unique list of prime numbers that, when multiplied,...

    The prime factorization of a number is the unique list of prime numbers that, when multiplied, gives the number. For example, the prime factorization of 60 is 2 ∗ 2 ∗ 3 ∗ 5. In this problem you must write code to recursively find and return the prime factorization of the given number. You must print these in ascending sorted order with spaces in between. For example, if your input is: 120 then you should print the following output: 2...

  • python programming Which of the following code will print all odd numbers between 3 and 11,...

    python programming Which of the following code will print all odd numbers between 3 and 11, each number separated by a space as shown below 35 7 9 11 for i in range(3, 11, 1): if 1%2 ID: print(i, end = " for i in range(3, 10, 2): print(i, end = for i in range, 11, 2): if 152 == 0: print(i, end = "") for i in range 12, 1): print(i, end = "")

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT