©2024 Compass Learning Technologies → GXWeb Showcase → GXWeb Jigsaws → GXWeb Primes Playground
GXWeb Primes Playground
Saltire Software, home of Geometry Expressions and GXWeb
Symbolic computations on this page use the Nerdamer Symbolic JavaScript to complement the in-built computer algebra system of GXWeb.
The beautiful mathematics you see on this page is made possible using MathQuill and MathJax.
Learn How: Create Your Own GXWeb Tasks (like this one!)
Learn How: Add Beautiful Mathematics to your Web Page
GXWeb Primes Playground: YouTube (10:41)
Playing with Primes: Introduction
2024 is definitely not a prime year, so when was the last one?
And when will the next one occur?
Did you know that there have been only 3 prime years so far this century? Can you name them?
And the next pair of twin primes?
If mathematics can be thought of as the study of patterns and relationships, then it is probably not surprising that prime numbers have been an equal source of fascination and frustration for so many through the ages.
Unlike the majority of well-behaved numbers, primes defy efforts to predict and categorise, and yet are among the most useful, especially in these days of increasingly challenging cyber security. It is their very unpredictability that makes primes a crucial element in the industries reliant upon them to safeguard all manner of information, from national and international right down to individual levels.
If we are to understand and try to predict prime numbers, then we might start with their complements, composite numbers - those that have factors other than themselves and 1. Modern computer algebra systems (CAS - such as Wolfram Alpha/Mathematica and Nerdamer) are adept at expressing numbers in terms of their prime factors.
For example, try pfactor(288), or pfactor(3240) or even pfactor(123454321)!
Try some yourself and think about how this might be done without the aid of CAS - how were such calculations made in the past, when exploring larger numbers? And then eliminating all those numbers with factors to find just the primes! How would they have found the 100th prime number - or the 1000th and beyond?
Those early mathematicians were, however, clever, patient and resourceful. In 1770 John Wilson found that, if and only if p is prime, then ((p−1)!+1) is a multiple of p (a result apparently previously known to Liebniz, and then proved in 1773 by Lagrange).
But hold on... It follows then that if p is prime, then (p−1)!+1p must be a whole number - and we have a way to identify primes!
Almost 200 years later, C.P. Willans came up with a clever way to simplify the process even more: noting that y=cos(π⋅(x)) is equal to 1 or -1 for all integers, and values between -1 and 1 for others. Even simpler, square those results (making all -1 values equal to 1) and take the floor of all values, and we have Willans' Formula which gives a value of 1 for all primes and 0 for non-primes!
isPrime(n)=⌊(cos(π⋅((n−1)!+1n))2⌋For example, isPrime(1117)=⌊(cos(π⋅((1116)!+11117))2⌋=1isPrime(1119)=⌊(cos(π⋅((1118)!+11119))2⌋=0
The real genius of Willans' formula, however, lies in the fact that all those 1s add up to the number of that prime:
Prime p will be the nth prime, where
n=(p)∑i=0(willans(i))For example, to find the 5th prime, count from the left:
(11)∑i=0(willans(i))
n 0 1 2 3 4 5 6 7 8 9 10 11 n∑i=0willans(i) 0 0 1 1 0 1 0 1 0 0 0 1 sum ⇒ prime - - 1 2 - 3 - 4 - - - 5 In the MathBox, enter prime(100) to find the 100th prime.
One note on the down side for Willans Formula: factorials grow Very Big Very Quickly, and even modern computers struggle to retain accuracy for long. It takes a system like Mathematica to produce accurate results beyond 100 or so. The free browser-based CAS Nerdamer does a great job and produces accurate results right up to n=170: try 170!+1 and then see what happens after that!
On the plus side, modern browser technology is very fast and very good at repetitive computation. If we wanted to check if a number n is prime, we could just check if any numbers divide evenly into n - and as a bonus, we only have to check numbers up to √(n) (can you explain why?)
Prime Challenge 1
It is probably not surprising that more primes occur in the first numerical century (the first 100 numbers) than in any other, but how are they distributed after that? Does each century have a decreasing number of primes?
If not, then within the first 20 centuries, which (after the first) are the most populous?
Prime Challenge 2
Do you remember those twin primes mentioned above? These really are unpredictable in their occurrence - or are they?
Every pair of twin primes other than 3 and 5 are of the form 6n±1 - BUT not every number of this form is part of a prime pair! For example,331=6⋅55+1 but 329=7⋅47 and 333=32⋅37
If you look closely at the Primes Array when you use isPrime() or Willans() in the MathBox, you will notice that the primes are coloured red and blue. Each blue prime signals that you will find its Prime Pair partner two units before it, and you can easily count the number of pairs in a range of values by counting the blue primes!
So can you be the first to discover a pattern in the distribution of twin primes?
About the MathBoxes...
Hint: When entering mathematical expressions in the math boxes below (f, g and h), use the space key to step out of fractions, powers, etc. On Android, begin entry by pressing Enter.
Type simple mathematical expressions and equations as you would normally enter these: for example, "x^2[space]-4x+3", and "2/3[space]". For more interesting elements, use Latex notation (prefix commands such as "sqrt" and "nthroot3" with a backslash (\)): for example: "\sqrt(2)[space][space]".
a= -1 5 1 b= -1 5 1 c= -1 5 1 d -1 0 5 e -1 0 5
Continued Fraction Spreadsheet Explorer
This browser-based spreadsheet uses the handsontable JavaScript library.
WolframAlpha: CAS+
Sometimes, to deal with those stubborn, hard to reach problems, you need something stronger!
The powerful Wolfram Alpha online CAS engine will answer almost anything you care to ask - within reason! From the continued fraction of pi to Solve x^2=x+1 to the population of Australia!
GeoGebra
GeoGebra offers another fast and accurate CAS alternative. You may also like to explore the GeoGebra web app.
Timing: Key Signature:
Share with QR Code
QR Codes are a great way to share data and information with others, even when no Internet connection is available. Most modern devices either come equipped with QR readers in-built, or freely available.
The default link here is the GXWeb Jigsaws and Quizzes, but you can use it as an alternative to sending your assessment data via email, web or share with others in your class. You can even use it to send your own messages!
GXWeb Jigsaws and Quizzes
Share Your Results
Enter your name:
My class:
Email to:
Session report length: 0 characters.
Turtle Robot Controls
Imagine designing, building and even remotely controlling your own robot! It is probably easier than you might think!
Alternatively, grab a TI Innovator Robot already made and follow the directions to "hack the hub"!
Watch the YouTube video of our GX Robot.
Follow the tutorial step-by-step directions to build and program your Arduino or TI Innovator robot.
NOTE: If using iPad or iPhone, you will need to grab the free Bluefy app to access webBluetooth since most browsers on this platform do not have this capability.
Then just connect and use your LOGO commands to steer - or use the controls below to connect and drive!
NOTE: Different surfaces and different robots will require different traction values. Try different values for distance and turn angle here until you find those that work best for your situation.
Distance Traction
Turn Traction
Manual Robot Controls
Playing with Primes: Step by Step Guide
Nerdamer: pfactor
Enter pfactor(288)
Enter isprime(289)
You can also simply use willan
Enter willan(289)
Like to know the 100th prime number? Or even the 1000th?
Enter prime()
You might also use Willan's Formula to see if a number is prime - isPrime(1117)=⌊(cos(π⋅((1116)!+11117))2⌋=1isPrime(1119)=⌊(cos(π⋅((1118)!+11119))2⌋=0
Willan's Formula returns 1 if the argument is prime and 0 if it is composite!
This allows us to find the nth prime. For example, to find the 5th prime, count from the left:
n 0 1 2 3 4 5 6 7 8 9 10 11 n∑i=0willan(i) 0 0 1 1 0 1 0 1 0 0 0 1 sum ⇒ prime - - 1 2 - 3 - 4 - - - 5
Enter isPrime() OR sum(i=0)[space][space](11) [space][space] (willan(i)) (11)∑i=0(willan(i))
Construct your own Model with GXWeb
Behind the Scenes
©2024 Compass Learning Technologies ← GXWeb Showcase ← GXWeb Jigsaws ← GXWeb Primes Playground