Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- #Display all prime numbers from 1-100
- def main():
- print('Here are all the prime numbers from 1 to 100')
- for num in range(1, 101):
- result = is_prime(num)
- if result:
- print(result)
- else:
- pass
- def is_prime(num):
- squared_num = math.sqrt(num)
- squared_num = int(squared_num)
- if num % 2 == 0:
- return False
- for x in range(3, squared_num + 2, 2):
- if num % x == 0:
- return False
- return num
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement