Skip to content · ⁨Pular para o conteúdo⁩

Digital root · ⁨Raiz digital⁩

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.

Português

Raiz digital

Continue somando dígitos até restar um único dígito.

Dois loops funcionam juntos aqui. O for interno soma os dígitos uma vez; str(n) permite iterá-los como caracteres. O while externo repete isso enquanto o número ainda tiver dois ou mais dígitos, ou seja, enquanto n >= 10.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP