By Alex Paixão, UNIME Brazil
In the world of mathematics to find out if a number is divisible by another there is a rule called severability rule. A natural number is divisible by 3 as the sum of all its digits forms a number divisible by 3, i.e. a multiple of 3 .
Ex1: 1.104 is divisible by 3?
Answer: “YES”. It is divisible by 3 , when added as their numbers : 1 + 1 + 0 + 4 = 6 , which is a number divisible by 3 (because 6 ÷ 3 = 2, which is a natural number).
Ex1: 2.791.035 is divisible by 3?
Answer: “YES” . 2791035 consists of figures added : 9 + 7 + 2 + 1 + 0 + 3 + 5 = 27 , generates a number divisible by 3 (because 27 ÷ 3 = 9 , natural number).
The input file contains two numbers n (1< n <10) indicating the number of digits m, (1< m < 1000000000).
The input ends with end of file (EOF).
Your program should provide the number of the sum of the digits of m and after presenting "sim" if the number is divisible by 3 or "nao" if not. Do not forget the finish line after the product, otherwise your program will display the message: "Presentation Error".
Input Sample | Output Sample |
3 111 1 1 2 24 |
3 sim 1 nao 6 sim |