Module: subroutines. recursion


Problem

8/12

Recursive translation: number in octal number system

Theory Click to read/hide

Recursive translation of a number from one number system to another

In in some situations in procedures, you can use the word return  without an argument - that is, in fact, the procedure still does not return anything. This can be useful when recursing, when return  is used to end the descent at base cases of parameter values ​​being recursed over. For example, a procedure that converts a number from decimal to binary may look like this: static void printTwo(int n) {     if (n == 0) return;   printTwo(n / 2);   if (n % 2 == 0) Console.Write(0);   else Console.Write(1); }

Problem

Write a recursive procedure that converts a number from decimal to octal. 

Input
The input to the program is the number N (N < 1024) - a number in the decimal number system.

Imprint 
Display one number on the screen - a number in the octal number system.
Examples
# Input Output
1 66 102