@lakshayarora7/

DistortedAstonishingSilverfish

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.35850518181666535","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"IyMgQSBwcm9ncmFtIHRvIHByaW50IHByaW1lIG51bWJlcnMgaW4gYW4gaW50ZXJ2YWwgb2YgMCB0byB0aGUgbnVtYmVyIGVudGVyZWQgYnkgdGhlIHVzZXIuDQoNCiMjIFByaW1lcyBhcmUgaW50ZWdlcnMgZ3JlYXRlciB0aGFuIG9uZSB3aXRoIG5vIHBvc2l0aXZlIGRpdmlzb3JzIGJlc2lkZXMgMSBhbmQgaXRzZWxmLiBOZWdhdGl2ZSBudW1iZXJzIGFyZSBleGNsdWRlZC4NCg0KdXBwZXJCb3VuZCA9IGludChpbnB1dCgiUGxlYXNlIGVudGVyIHRoZSB1cHBlciBib3VuZCBvZiByYW5nZToiKSkNCg0KZm9yIG51bWJlciBpbiByYW5nZSgxLHVwcGVyQm91bmQgKyAxKTogICMgdGVzdGluZyBhbGwgbnVtYmVycyBpbiByYW5nZSAxIHRvIHVwcGVyQm91bmQNCiAgIGlmIG51bWJlciA+IDE6ICAgICAgICAgICAgICAgICAgICAgICAjIHByaW1lIG51bWJlcnMgYXJlIGdyZWF0ZXIgdGhhbiAxLCB0aGUgc21hbGxlc3QgcHJpbWUgbnVtYmVyIGlzIDIuDQogICAgICAgZm9yIGkgaW4gcmFuZ2UoMixudW1iZXIpOiAgICAgICAgIyB0ZXN0aW5nIGFsbCBudW1iZXJzIGluIHJhbmdlIDIgdG8gKG51bWJlciAtIDEpDQogICAgICAgICAgIGlmIChudW1iZXIgJSBpKSA9PSAwOiAgICAgICAgIyBpZiB0aGUgbnVtYmVyIGhhcyBhbnkgZmFjdG9yIG90aGVyIHRoYW4gaXRzZWxmLCB0aGVuIGJyZWFrIG91dCBvZiB0aGUgaW5uZXIgZm9yIGxvb3ANCiAgICAgICAgICAgICAgIGJyZWFrDQogICAgICAgICAgIGVsc2U6ICAgICAgICAgICAgICAgICAgICAgICAgIyBpZiB0aGUgbnVtYmVyIGRvZXNuJ3QgaGF2ZSBhbnkgZmFjdG9yIG90aGVyIHRoYW4gaXRzZWxmLCBwcmludCBpdCBhcyBhIHByaW1lLg0KICAgICAgICAgICAgICAgcHJpbnQobnVtYmVyKQ0KICAgICAgICAgICAgICAgYnJlYWs="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## A program to print prime numbers in an interval of 0 to the number entered by the user.

## Primes are integers greater than one with no positive divisors besides 1 and itself. Negative numbers are excluded.

upperBound = int(input("Please enter the upper bound of range:"))

for number in range(1,upperBound + 1):  # testing all numbers in range 1 to upperBound
   if number > 1:                       # prime numbers are greater than 1, the smallest prime number is 2.
       for i in range(2,number):        # testing all numbers in range 2 to (number - 1)
           if (number % i) == 0:        # if the number has any factor other than itself, then break out of the inner for loop
               break
           else:                        # if the number doesn't have any factor other than itself, print it as a prime.
               print(number)
               break