Use Regx To Find Prime Numbers

Base on: How on Earth does ^.?$|^(..+?)\1+$ produce primes?

Introduction

import re n = 13 # an integer to test x = re.match(r'^.?$|^(..+?)\1+$','1'*n) if x is None: print() print(f'{n} is a prime number') else: print() print(f'{n} is not a prime number')

Project #1

Create and interactive program:

  1. asks the users to input a positive integer
  2. test if the integer is a prime number
  3. display the integer
  4. display if it is a prime or not
  5. loop

Note: set reasonable limits on the input integer.

Project #2

Convert Project #1 into a GUI.