mirror of
https://github.com/flancian/garden.git
synced 2026-08-07 23:16:21 +00:00
autopushed
This commit is contained in:
+4
-3
@@ -8,7 +8,7 @@ import math
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# I'm not proud (I am a little bit?).
|
# I'm not proud (I am a little bit?).
|
||||||
global SIEVE
|
SIEVE = []
|
||||||
PROOF = [] # :)
|
PROOF = [] # :)
|
||||||
|
|
||||||
def factor(n):
|
def factor(n):
|
||||||
@@ -43,7 +43,7 @@ def is_prime(n):
|
|||||||
SIEVE[i*j] = False
|
SIEVE[i*j] = False
|
||||||
except IndexError:
|
except IndexError:
|
||||||
continue
|
continue
|
||||||
return n >= 2 and SIEVE[n]
|
return (n >= 2 and SIEVE[n], SIEVE)
|
||||||
|
|
||||||
class AgoraCmd(click.Command):
|
class AgoraCmd(click.Command):
|
||||||
def format_help(self, ctx, formatter):
|
def format_help(self, ctx, formatter):
|
||||||
@@ -70,7 +70,8 @@ class AgoraCmd(click.Command):
|
|||||||
@click.argument('n', type=click.INT)
|
@click.argument('n', type=click.INT)
|
||||||
def prime(n):
|
def prime(n):
|
||||||
"""Simple program that factors a number using a [[Sieve of Eratosthenes]]."""
|
"""Simple program that factors a number using a [[Sieve of Eratosthenes]]."""
|
||||||
if is_prime(n):
|
p, sieve = is_prime(n)
|
||||||
|
if p:
|
||||||
click.echo(f"[[{n}]] is prime.")
|
click.echo(f"[[{n}]] is prime.")
|
||||||
else:
|
else:
|
||||||
click.echo(f"{n} is not prime. Want proof? :)")
|
click.echo(f"{n} is not prime. Want proof? :)")
|
||||||
|
|||||||
Reference in New Issue
Block a user