o

T
w
o
H

ACSL
Contest #1

Contest 1 Topics
Intermediate:
Computer Number Systems - two bases - 2
Recursive Functions - Not nested - 2
What Does This Program Do? - Branching - 1
Senior:
Computer Number Systems - multiple bases - 2
Recursive Functions - Nested - 2
What Does This Program Do? - Branching and Loops - 1

Computer Number Systems



Computers use numbers with different bases such as base 2
(binary), 8 (octal), 10 (decimal), and 16 (hexadecimal).
Base 10 is what regular, everyday numbers are in
Examples of different bases will be represented as 10100102,
1018, A3116, and base ten is written without a subscript.
When the digit is above 9, letters are used
A=10, B=11, C=12, D=13, E=14, F=15

CNS-Base to Decimal

Each digit place represents the
base to a higher power.
Multiply the digit in the column
with the base raised to the
correct power
Add up all the products to find
the number value in base ten
(decimal).
Binary to Decimal is shown on
the right, but the same process
is used for any base

CNS-Decimal to Base


To convert a decimal number to
a different base, create columns
with the base to increasing
powers.
Start with the base to the 0th
power for the last digit
Write how many times the value
of that column fits in the decimal
number and subtract it from the
decimal number
Put a 0 if the column value
doesn’t fit and move onto the
next column

0
0
0
0
0
0
0
0
1
1
1

0
0
0
0
0
0
0
1
0
1
1

0
0
0
0
0
0
1
1
1
0
1

0
0
0
0
0
1
1
1
0
0
1

0
0
0
0
1
1
1
0
0
1
1

0
0
0
0
1
0
0
1
0
0
1

0
0
1
1
1
1
0
0
0
0
1

0
1
0
1
1
1
0
1
0
0
1

CNS- Base to Base

To convert from base to base, you can convert the first number to decimal and then
convert the decimal number to the second base.
To go straight from binary to hexadecimal, break up the binary in chunks of four digits and
convert each chunk into decimal. So break up 1001010000112 as 1001 0100 00112 and
convert each chunk to decimal to get 94316.

To convert hexadecimal to binary, represent each digit in binary. So 72516 would equal
0111001001012

To convert binary to octal is a similar process. Break up the binary number into chunks of
three digits. Example: 1101001001 becomes 001 101 001 001. This becomes 15118. The
same process works in reverse: 73328 becomes 111 011 011 010

Recursive Functions



Given a function with different outputs for ranges of inputs
All but one output call the function again, one output is a
constant
Keep solving the function until the output does not call the
function again.
Substitute value in preceding equation to find output for
original input.

Recursive Functions

1.
2.
3.
4.
5.
6.
7.
8.
9.

150>100 so use the first output: f(150)=f(150-20)+10=f(130)+10
Now solve for f(130)
130>100 so use the first output: f(130)=f(130-20)+10=f(110)+10, solve for f(110)
110>100 so use the first output: f(110)=f(110-20)+10=f(90)+10, solve for f(90)
90<100 so use the second output: 3(90)=270
Now that we know f(90)=270, substitute it in the previous equation
f(110)= f(90)+10 = 270+10 = 280, now substitute in previous equation
f(130)= f(110)+10 = 280+10 = 290
f(150)= f(130)+10 = 290+10 =300

Recursive Functions
Senior division topics:
Nested recursion:
f(f(f(54)))
Multiple variables: (2014 contest)

Word Problem: (2015)

What Does this Program Do

This question will just deal with reading a program and
figuring out the end value of a variable based on the function
The function may include arithmetic expressions, loops, conditional
statements, and string manipulation