Digital Root Calculator
정수의 각 자릿수를 반복적으로 합하여 디지털 근(digital root)을 계산하고 단계별 과정과 가산 영속성을 표시합니다.
가법 디지털근: 한 자리 수가 남을 때까지 숫자를 반복해서 더합니다.
승법 디지털근: 한 자리 수가 남을 때까지 숫자를 반복해서 곱합니다.
이 도구 소개
디지털근(digital root)은 어떤 수의 각 자릿수를 반복적으로 더해 결국 한 자리 수가 될 때까지 계산한 결과값입니다. 이 과정은 수비학, 모듈로 연산, 수학 퍼즐의 기초가 되며, 모든 정수가 가진 잠재적인 디지털 지문을 드러냅니다. 디지털근 계산기는 이 반복 과정을 자동화하여 각 단계의 계산과 최종 한 자리 결과, 그리고 필요한 반복 횟수(가법적 지속성이라 부릅니다)를 보여 줍니다.
사용 방법은 매우 간단합니다. 어떤 양의 정수를 입력하기만 하면 전체 축약 수열——각 단계에서 자릿수가 어떻게 합쳐지는지——이 표시되고, 최종 한 자리 결과와 반복 횟수가 나타납니다. 자릿수 합을 배우는 학생, 수의 성질을 시연하는 교육자, 큰 수 속에 숨겨진 재귀적 구조에 호기심 있는 사람에게 유용합니다.
유용한 통찰로, 디지털근은 9로 나눈 나머지와 관련이 있습니다. 어떤 수의 디지털근은 그 수를 9로 나눈 나머지와 같습니다(9의 배수는 특별한 처리를 받습니다). 모든 계산은 브라우저 안에서 로컬로 실행되므로 기기를 벗어나지 않고도 원하는 만큼 디지털근을 탐구할 수 있습니다.
자주 묻는 질문
코드 구현
def digit_sum(n: int) -> int:
return sum(int(d) for d in str(abs(n)))
def digital_root(n: int) -> int:
"""Returns the additive digital root (1-9, or 0 for 0)."""
if n == 0:
return 0
remainder = n % 9
return remainder if remainder != 0 else 9
def additive_persistence(n: int) -> tuple[int, list[int]]:
steps = [n]
count = 0
while n >= 10:
n = digit_sum(n)
steps.append(n)
count += 1
return count, steps
def multiplicative_digital_root(n: int) -> tuple[int, list[int]]:
steps = [n]
count = 0
while n >= 10:
product = 1
for d in str(n):
product *= int(d)
n = product
steps.append(n)
count += 1
return count, steps
n = 493
print(f"Digital root of {n}: {digital_root(n)}")
persistence, steps = additive_persistence(n)
print(f"Steps: {' -> '.join(map(str, steps))}")
print(f"Additive persistence: {persistence}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.