C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
enum OPERATION
{
ADD = 1,
SUBTRACT,
MULTIPLY,
DIVIDE,
MOD,
LSHIFT,
RSHIFT,
AND,
XOR,
OR
};
/*#define DEBUG
#ifdef DEBUG
const char* ops[] = { "+", "-", "*", "/", "%", "<<", ">>", "&", "^", "|" };
#endif*/
// recursive function that applies an operation
// on each digit of number <n>.
// never been tested with negative input
// Fixed with help from @jtrh and @XXX
int rec( int n, int op )
{
if( n > 9 )
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run