Somma delle cifre 2

2013-05: Small 1
Write a program that finds all the numbers less than 1000 that contain only digits that sum to 10, e.g. 55, 73, 137, but not 423.
How many are there?
2012-11: Math 1
Find all the numbers less than 1000, where the sum of the digits is 15, for example 96 or 177.
How many are there?
If you fancy a further challenge, then calculate how many numbers less than 1000 there are that have a sum of digits equal to each of the possible values (not just 15, i.e. 1, 2, 3 … 25, 26, 27).

Scrivi un programma che trova tutti i numeri minori di 1000 la cui somma delle cifre sia uguale a 10 (15). Quanti sono?
Come ulteriore sfida calcola quanti numeri hanno come somma ciascun possibile valore da 1 a 27.

Soluzione

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *