What is Nostr?
dula / DULA
npub1cta…ucne
2023-05-11 16:40:02
in reply to nevent1q…cef4

dula on Nostr: #[1]​ could you please check this Python code? All prime numbers are congruent to 5 ...

dave (npub1tsg…htk4)​ could you please check this Python code? All prime numbers are congruent to 5 and 7 also all permutations among primes are congruent to 5 and 7 in this Sieve.
( please see the Chinese reminder theorem )

import sympy
from tkinter import *
from tkinter import messagebox

# Function to generate and display the prime factorizations of composite numbers
def generate_factorizations():
# Get the custom limit from the input box
limit = int(limit_input.get())

# Generate all the composite numbers congruent to 1, 5, and 7 modulo 6 up to the custom limit
nums = []
for n in range(25, limit + 1):
if n % 6 in (1, 5, 7, 11) and not sympy.isprime(n):
nums.append(n)

# Generate the prime factorization of each composite number
factorizations = {}
for n in nums:
factorizations[n] = sympy.factorint(n)

# Clear the existing output text and display the factorizations in the desired format
output_text.delete('1.0', END)
for n, factors in factorizations.items():
output_text.insert(END, f"{n} = {' x '.join(str(p) + '^' + str(e) for p, e in factors.items())}\n")

# Check if all the factors are prime numbers
all_primes = all(all(sympy.isprime(p) for p in factors.keys()) for factors in factorizations.values())

# Display a message box with the result
if all_primes:
messagebox.showinfo("All prime factors", "All factors in the output are prime numbers.")
else:
messagebox.showwarning("Not all prime factors", "Some factors in the output are not prime numbers.")

# Create the main window and widgets
root = Tk()
root.title("Prime Factorization Generator P ≡ 1, 5, 7, 11 MOD 6")

limit_label = Label(root, text="Enter a limit:")
limit_label.grid(row=0, column=0)

limit_input = Entry(root)
limit_input.grid(row=0, column=1)

generate_button = Button(root, text="Generate Factorizations", command=generate_factorizations)
generate_button.grid(row=1, column=0, columnspan=2)

output_label = Label(root, text="Prime factorizations:")
output_label.grid(row=2, column=0)

output_text = Text(root, height=20, width=50)
output_text.grid(row=3, column=0, columnspan=2)

root.mainloop()
Author Public Key
npub1ctagm8mys2he926jqxcfph4vz3kjqzmxxch5ysstxqxtvl0uuz4qgwucne