This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#소수구하는 모듈인 primesieve로 일단 구함. 그중에 고름 | |
#순환소수인지 판별할 때는 순열조합 모듈인 itertools.permutations를 사용 | |
import primesieve | |
def is_circular_prime(num): | |
for 검사해야할num in permutations(str(num)): | |
검사해야할num = int(''.join(검사해야할num)) | |
if 검사해야할num == 소수: | |
result = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
from collections import deque | |
import primesieve | |
#def is_prime(num): | |
# result = False | |
# for i in range(2, num): | |
# if num > 2 and num % i == 0 : | |
# return False | |
# else : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
from math import factorial | |
def get_factorial_num(range_from, range_to): | |
result_sum = 0 | |
for num in range(range_from, range_to): | |
list_num = list(str(num)) | |
sum = 0 | |
for i in list_num : | |
sum = sum + factorial(int(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
import math | |
square_arr = [] | |
for i in range(0, 10) : | |
square_arr.append(i ** 5) | |
def sum_out_squares_of_five(*args) : | |
result = 0 | |
for a in args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
def get_square_set(a_range_to, b_range_to) : | |
square_list = set() | |
for a in range(2, a_range_to+1) : | |
for b in range(2, b_range_to+1) : | |
square_list.add(a**b) | |
return len(square_list) | |
print(get_square_set(100, 100)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
#1. 일단 규칙부터 찾고 | |
#2. 차근차근 더함 | |
def sum_one_square(first_num, nth) : | |
result_sum = 0 | |
for i in range(1, 5) : | |
next_num = first_num + 2*i*nth | |
result_sum += next_num | |
return result_sum, next_num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
# n2 + an + b (단 | a | < 1000, | b | < 1000) | |
# 연속된 n에 대해 가장 많은 소수를 만들어내는 2차식을 찾아 a*b를 구해라 | |
import cProfile | |
def is_prime_num(num) : | |
if num <= 1 : return False | |
for i in range(2, int(num**0.5) + 1): | |
if num % i==0: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
import re | |
def cal_unit_fraction(denominator) : | |
return re.findall('.(\d+)', str(1/denominator)) | |
def cal_recurring_cycle(deno) : | |
num_list = cal_unit_fraction(deno) | |
int(num_list[0]) | |
for num in num_list : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
def cal_fibo(digit) : | |
num1 = 1 | |
num2 = 1 | |
seq = 3 | |
while True : | |
num3 = num1 + num2 | |
num1 = num2 | |
num2 = num3 | |
if len(str(num3)) >= digit : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
import itertools | |
def cal_lexicographic_permutation(range_to) : | |
seq = 1 | |
num = '0123456789' | |
num_list = itertools.permutations(num) | |
for lexi_num in num_list : | |
if seq == range_to : | |
return "".join(lexi_num) |