import sys
import time
# Remove the limit
sys.set_int_max_str_digits(0)
i = 0
def signal_handler(sig, frame):
global i
if sig == signal.SIGINT:
print("index = %i" % (i))
sys.exit(0)
def int_sqrt(n):
"""
Calculate the integer square root of a non-negative integer n.
This function returns the largest integer whose square is less than or equal to n.
"""
if n < 0:
raise ValueError("Cannot calculate square root of a negative number.")
if n == 0:
return 0
x = n
y = 1
i = 0
while x > y:
x = (x + y) // 2
y = n // x
return x
def prime_power(n):
signal.signal(signal.SIGINT, signal_handler)
total = 0
half_n = (n + 1) // 2
# limit = half_n
# limit = math.ceil((half_n*(half_n + 1) // 2 + 1) / n)
limit = (n + 13)//8
start_time = time.perf_counter()
end_time = start_time
global i
for i in range(2, limit):
# border_value represents the number that ends on the last
# column when all numbers up to it are added and wrapped.
border_value = int((int_sqrt(8 * i * n + 1) - 1)/2)
total = (border_value * (border_value + 1)//2)
elapsed_time = end_time - start_time
if (total == (i * n)):# or (total + (border_value + 1)//2 == (i * n)):
print("%i" % (border_value))
return
end_time = time.perf_counter()
elapsed_time = end_time - start_time
if elapsed_time > WAIT_TIME:
start_time = end_time
end_time = time.perf_counter()
print("\tprime_power")
print("p\tborder\tprime power")
prime_power(2**89-1)
Showing posts with label Fermat. Show all posts
Showing posts with label Fermat. Show all posts
Saturday, April 26, 2025
My Mersenne Primality Testing Algorithm
I'm not sure how fast it is compared to GIMPS, but it is acurate for all Mersenne or Fermat primes. See my article Value-Counting Up to N for why.
Sunday, July 31, 2022
Value-Counting Up to N
Some interesting properties arise when value-counting the integers sequentially up to N using N digits or fingers and comparing the number of values to the prime-exact equation; with a simple method for testing primes and prime powers (particularly Mersenne and Fermat primes).
Click here to read my paper.
Click here to read my paper.
Saturday, March 26, 2016
Fermat's Last Theorem Prize Approved
It was a problem that had baffled mathematicians for centuries -- until British professor Andrew Wiles set his mind to it.
"There are no whole number solutions to the equation xn + yn = zn when n is greater than 2."
Otherwise known as "Fermat's Last Theorem," this equation was first posed by French mathematician Pierre de Fermat in 1637, and had stumped the world's brightest minds for more than 300 years.
In the 1990s, Oxford professor Andrew Wiles finally solved the problem, and this week was awarded the hugely prestigious 2016 Abel Prize -- including a $700,000 windfall.
Click here for more information.
"There are no whole number solutions to the equation xn + yn = zn when n is greater than 2."
Otherwise known as "Fermat's Last Theorem," this equation was first posed by French mathematician Pierre de Fermat in 1637, and had stumped the world's brightest minds for more than 300 years.
In the 1990s, Oxford professor Andrew Wiles finally solved the problem, and this week was awarded the hugely prestigious 2016 Abel Prize -- including a $700,000 windfall.
Click here for more information.
Labels:
Abel Prize,
award,
Fermat,
mathematician,
prize
Wednesday, May 09, 2007
The Simpsons


The longest running animation TV show of all time and one of the best cartoons ever. Known for covering humor on every subject. Here' are a couple on Fermat's Last Theorem, Euler's Formula and the Complexity classes P and NP.
Subscribe to:
Posts (Atom)