Skip to content · ⁨본문 바로가기⁩

Digital root

English

Digital root

Keep adding digits until a single digit remains.

Two loops work together here. The inner for adds up the digits once; str(n) lets you loop over them as characters. The outer while repeats that as long as the number still has two or more digits, which is while n >= 10.

한국어

디지털 루트

한 자리 숫자가 남을 때까지 숫자를 계속 더하십시오.

여기서 두 개의 루프가 함께 작동합니다. 내부 for은 숫자를 한 번 더하고; str(n)은 이를 문자열로 순회하게 해줍니다. 외부 while은 숫자가 두 자리 이상일 동안(즉, n >= 10일 때) 그것을 반복합니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP