Problem 60991. Search for seesaw primes
Cody Problem 60958 introduced seesaw numbers. A number x is a seesaw number if the next m smaller numbers can be placed on a seesaw to the left of x at the fulcrum and the n larger numbers can be placed to the right to make the net torque about the fulcrum zero. Recall that the torque is equal to the product of the number and its distance from the fulcrum. Let’s take torque leading to counterclockwise rotation as positive and torque leading to clockwise rotation as negative.
This problem deals with seesaw primes, which are like seesaw numbers except that they use primes instead of integers. The number 11 is not a seesaw prime because no values of m and n can be found to make the net torque zero. The minimum value of torque of 2 units occurs with one prime (7) to the left and one prime (13) to the right—i.e.,
.
The number 167 is a seesaw prime because with six primes on the left (137, 139, 149, 151, 157, 163) and five on the right (173, 179, 181, 191, 193) the torque on the left is 15,322 units, the torque on the right is -15,322 units, and the net torque is zero.
Seesaw primes seem to be rare: 167 and 17,750,989 are the only ones smaller than 20,000,000. Although the envelope of the minimum torques increases, the dense cluster of points around zero on a plot with linear axes suggests suggests that other seesaw primes should be possible. A plot of the absolute value of the minimum torque
on semilog axes is less encouraging: for primes between 1 and 20 million, only thirteen have an absolute value of minimum torque less than 72 units.
Write a function to determine whether the input number is a seesaw prime. Also return the minimum torque, and m and n, the number of primes on the left and right when the minimum torque occurs. At least one of m and n must be greater than zero. If the input is not prime, set m, n, and the minimum torque to NaN.
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
Matthew
on 4 Aug 2025
Another fantastic ChrisR special!
ChrisR
on 5 Aug 2025
Thanks Matthew. And nice job on the code. It's much faster than mine!
ChrisR
on 14 Aug 2025
Thank you, Tim--fixed.
I also updated the description to include the second seesaw prime.
Tim
on 14 Aug 2025
Oops--I deleted my earlier comment (intending to revise it) before I saw that you responded--never mind.
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
3 Solvers
More from this Author311
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!