Fun with the Fractional
Part function and Integers
Let
n be a integer and frac(n) be the fractional part function. For example, frac(28.38) = 0.38.
Alternating Ones and Zeros – Ones Assigned to Odd Numbers
f(n)
= 2 * frac(n/2) = n mod 2
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
0
|
1
|
0
|
1
|
0
|
1
|
0
|
1
|
0
|
Alternating Ones and Zeros – Ones Assigned to Even Numbers
f(n)
= 2 * frac((n + 1)/2)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
0
|
1
|
0
|
1
|
0
|
1
|
0
|
1
|
0
|
1
|
Alternating Integers – Integers Assigned to Odd Numbers, Zeros to
Even
f(n)
= (2*n) * frac(n/2)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
0
|
3
|
0
|
5
|
0
|
7
|
0
|
9
|
0
|
Alternating Integers – Integers Assigned to Even Numbers, Zeroes to
Odd
f(n)
= (2*n) * frac((n+1)/2)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
0
|
2
|
0
|
4
|
0
|
6
|
0
|
8
|
0
|
10
|
Alternate +1 and -1. Use of
superposition of functions
f(n)
= (2) * frac((n+1)/2) + (-2) * frac(n/2)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
-1
|
1
|
-1
|
1
|
-1
|
1
|
-1
|
1
|
-1
|
1
|
The Number of Petals of a Rose Function
Odd
+ Even = (2*n)*frac(n/2) + (4*n)*frac((n+1)/2)
This
determines the number of pedals a rose gets.
The rose is represented by the polar equation r = cos(n*θ). If n is odd, the rose has n petals. If n is even, the rose has 2*n petals.
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
4
|
3
|
8
|
5
|
12
|
7
|
16
|
9
|
20
|
Other Examples
f(n)
= 3 * frac(n/3) = n mod 3
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
2
|
0
|
1
|
2
|
0
|
1
|
2
|
0
|
1
|
f(n)
= 3 * n * frac(n/3)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
2
|
0
|
4
|
10
|
0
|
7
|
14
|
0
|
10
|
f(n)
= 3 * n * frac((n+1)/3)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
2
|
0
|
3
|
8
|
0
|
6
|
14
|
0
|
9
|
20
|
f(n)
= 4 * frac(n/4) = n mod 4
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
1
|
2
|
3
|
0
|
1
|
2
|
3
|
0
|
1
|
2
|
f(n)
= 4 * frac(2*n/4) = 4 * frac(n/2)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
2
|
0
|
6
|
0
|
10
|
0
|
14
|
0
|
18
|
0
|
f(n)
= 4 * frac(3*n/4) (sort of “reversing” n mod 4)
n
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
f(n)
|
3
|
2
|
1
|
0
|
3
|
2
|
1
|
0
|
3
|
2
|
Generalizing:
Let
m and n be positive integers. Hence, m *
frac(n/m) = n mod m
To
reverse the sequence, use m * frac((m-1)*n/n)
Don’t
forget to play sometimes. Math can be
really fun when you let go.
Eddie
This
blog is property of Edward Shore, 2017.