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
Jobisdone [24]
2 years ago
6

Write a program that prompts the user for an integer and thenprints out all prime numbers up to that integer. For example,when t

he user enters 20, the program should print out:
2
3
5
7
11
13
17
19
Note: A prime number is not divisible by any number except 1and itself.
Computers and Technology
1 answer:
MaRussiya [10]2 years ago
8 0

Answer:

n=int(input("Enter number upto which you want to print prime numbers:\n"))#taking input of n in integer type..

for i in range(1,n): #looping over 1 to n.

   pr=True  #taking pr to be True..

   for div in range(2,i): #looping over 2 to i..

       if i%div==0:#if i is divisible by div then it is not prime

           pr=False#making pr false

   if pr and i!=1: #condition for printing

       print(str(i))#printing the prime numbers..

       

Explanation:

In the python program we have checked for every integer up to n that is is not divisible by any integer between 2 to n-1 both inclusive if it is then it is not a prime number.

You might be interested in
Hellpppppppppppppppp
jonny [76]

Answer:

i can't see your problem

6 0
2 years ago
Read 2 more answers
Technological advances have made cyberbullying
Tamiku [17]

Answer:

ok

Explanation:

6 0
3 years ago
Write a program that asks the user to enter a birth year. the program should then indicate which generation a person of that yea
USPshnik [31]
Something like the following. Also you need to give what language you are using. Anyways, you should be able to convert this to your language of choice. 

<script type="text/javascript">
function checkGeneration() { 
   var gen = ["Baby Boomer ","Generation X","Xennials","Generation Y"];
   var reversestr = "";
   var getyear = window.prompt("Enter a 3 digit number: ");
    if (parseInt(getyear) <= 1964) {
        alert(gen[0]);   
    } else if(parseInt(getyear) <= 1979) {
        alert(gen[1]);
    } else if(parseInt(getyear) <= 1985) {
        alert(gen[2]);               
   }  else if(parseInt(getyear) <= 1995) {
        alert(gen[3]);
   }
 }
checkGeneration();
</script>
7 0
2 years ago
I need someone's opinion<br> Which format is better? The first or second one? I can't decide 0.0
Ne4ueva [31]

Answer:

2nd one

Explanation:

4 0
3 years ago
Read 2 more answers
Round 74,361 to the nearest 10​
grandymaker [24]

Answer:

74,400 i think

Explanation:

8 0
3 years ago
Other questions:
  • Which program or security application prevents access between a private and trusted network, and other untrusted networks?
    8·2 answers
  • Which files track internet usage and personal information when people visit websites?
    14·2 answers
  • To delete a database object, right-click the object in the Navigation Pane and then click ____ on the shortcut menu.
    15·1 answer
  • On a spreadsheet, this is the term for a grouping of cells that touch each other and form a rectangle. An example of it would be
    13·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • Which word in brackets is most opposite to the word in capitals? PROSCRIBE (allow, stifle, promote, verify)​
    14·2 answers
  • A local cinema allows customer to make a movie ticket reservation. A customer can be
    6·1 answer
  • 2. What is the name for an action performed by the VR Robot?
    7·2 answers
  • Draw a flow chart to access the marks of three students. calculate the total avarage and display the result​
    11·1 answer
  • How does 5G technology enhance the Internet of Things (IoT)?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!