x = list(range(81234, 134689 + 1)) # sometimes it so slow. so I left you commented list below. You can try those list. The result is the same.
# x = [16, 81, 54, 12, 625, 45, 22, 96] # very fast
# x = [i for i in range(0, 1000)] # fast
numbers = []
for num in x:
if len(numbers) > 2: break
if str(num ** (0.5)).split(".")[1] != "0": continue
if len(get_dividers(num)) == 5: numbers.append(num)
for element in sorted(numbers): print(f"{element}: {sorted(get_dividers(element))}")
# the output will be 83521: [1, 17, 289, 4913, 83521]\n130321: [1, 19, 361, 6859, 130321]. thats because in those numbers interval no satisfying numbers.
# you can turn "x" above. and you'll see, that program works correctly
input("\nTap on Enter to continue...")
# second task:
def get_dividers(n):
dividers = []
for num in range(2, n-1):
if n % num == 0: dividers.append(num)
return dividers
x = 250200
predictions = []
while len(predictions) + 1 < 6: # you need wait a little bit. it continue on 250704
x += 1
dividers = get_dividers(x)
try:
if (max(dividers) + min(dividers)) % 123 == 17: predictions.append(x)
# if something doesn't work, you can write it in the comments, and i will answer you, and other ;)
0 votes Thanks 0
vjvjjvvjvj
Здравствуйте. Извините , не могли бы вы помочь с моим вопросом, он в профиле ?
Greenow
вопрос не закончен. я могу написать вам запросы на SQL прямо в табличку, могу на pymysql. а вдруг вам нужен вообще MariaDB, или Postgress
Greenow
поэтому и прошлые ваши вопросы остались без ответа. теперь лежат в ленте, извиняюсь, как мусор..
vjvjjvvjvj
Не укащывали, в какой именно БД нужно выполнять, поэтому я не знаю. Напишу, что это 9 класс, если нет чего-то определённого, то напишите в любой , буду благодарна и этому
Answers & Comments
# python 3+
# first task:
from collections import Counter
# below is algorithm, that show idea
def is_prime(n):
for num in range(2, n):
if n % num == 0: return False
return True
def next_prime_from(n):
if is_prime(n): n += 1
while True:
if is_prime(n): return n
n += 1
def get_multipliers(n):
multipliers = []
remainder = None
divider = 2
while remainder != 1:
if n % divider == 0:
remainder = n / divider
multipliers.append(divider)
n /= divider
continue
divider = next_prime_from(divider)
return multipliers
def canonically_decompose(n):
multipliers = get_multipliers(n)
decomposed = Counter(multipliers)
return decomposed
def get_divigions_count(n):
prediction = 1
degrees = []
nums = canonically_decompose(n)
nna = set(get_multipliers(n))
for element in nna: degrees.append(nums[element])
for count in degrees: prediction *= count+1
return prediction
# above is algorithm, that show idea
# you can play with it
# simple change of numbers
def get_dividers(n):
dividers = []
for num in range(n, 0, -1):
if (n % num == 0):
dividers.append(num)
return dividers
x = list(range(81234, 134689 + 1)) # sometimes it so slow. so I left you commented list below. You can try those list. The result is the same.
# x = [16, 81, 54, 12, 625, 45, 22, 96] # very fast
# x = [i for i in range(0, 1000)] # fast
numbers = []
for num in x:
if len(numbers) > 2: break
if str(num ** (0.5)).split(".")[1] != "0": continue
if len(get_dividers(num)) == 5: numbers.append(num)
for element in sorted(numbers): print(f"{element}: {sorted(get_dividers(element))}")
# the output will be 83521: [1, 17, 289, 4913, 83521]\n130321: [1, 19, 361, 6859, 130321]. thats because in those numbers interval no satisfying numbers.
# you can turn "x" above. and you'll see, that program works correctly
input("\nTap on Enter to continue...")
# second task:
def get_dividers(n):
dividers = []
for num in range(2, n-1):
if n % num == 0: dividers.append(num)
return dividers
x = 250200
predictions = []
while len(predictions) + 1 < 6: # you need wait a little bit. it continue on 250704
x += 1
dividers = get_dividers(x)
try:
if (max(dividers) + min(dividers)) % 123 == 17: predictions.append(x)
except ValueError: continue
for element in predictions:
dividers = get_dividers(element)
try: print(": ".join(list(map(str, [element, min(dividers) + max(dividers)]))))
except: continue
input("\nTap on Enter to continue...")
# if something doesn't work, you can write it in the comments, and i will answer you, and other ;)