Compare commits

6 Commits

Author SHA1 Message Date
flancian 7c468f4984 autopushed 2023-10-15 03:44:21 +02:00
flancian ed3548c4c2 autopushed 2023-10-15 03:39:53 +02:00
flancian 7dadc3b8f4 autopushed 2023-10-15 03:38:12 +02:00
flancian 4e74dfe77e autopushed 2023-10-15 03:37:38 +02:00
flancian a8cb793dfa autopushed 2023-10-15 03:36:30 +02:00
flancian 3506de5df3 autopushed 2023-10-15 03:25:18 +02:00
+3 -3
View File
@@ -18,7 +18,7 @@ def print_sieve(sieve):
primes = []
for n, prime in enumerate(sieve):
if n >= 2 and prime:
primes.append(str(n))
primes.append('[[' + str(n) + ']]')
return ", ".join(primes)
def is_prime(n):
@@ -73,9 +73,9 @@ def prime(n):
"""Simple program that factors a number using a [[Sieve of Eratosthenes]]."""
p, sieve = is_prime(n)
if p:
click.echo(f"*{n}* is *prime*.")
click.echo(f"**{n}** is **prime**.")
else:
click.echo(f"*{n}* is *not prime*. Want proof? :)")
click.echo(f"**{n}** is **not prime**. Want proof? :)")
click.echo("\n".join([line for line in PROOF if f'[[{n}]]' in line]))
click.echo(f"\nPrimes up to {n}: {print_sieve(sieve)}.")