Exercise 9

The first sequence turns out to be difficult to find a formula for. I quessed this formula based on some other sequences that I studied.

Clear[a, n];
a[n_] := 
        If[n - Floor[
                  (1/2) (1 + (Sqrt[4 n - 3]))] (Floor[
                      (1/2) (1 + (Sqrt[4 n - 3]))] - 1) ≤ 
            Floor[(1/2) (1 + (Sqrt[4 n - 3]))], 1, 0];

Table[a[n], {n, 1, 50}]

Clear[b, n];

    
b[1] = 1;  b[2] = 2; 

b[n_] := b[n] = 
        If[
Or[OddQ[b[n - 1]] == True, 
            b[n - 1] == b[n - 2]], b[n - 1] + 1, 
          b[n - 1]]

Table[b[n], {n, 1, 23}]

Clear[c, n];

    
c[n_] := If[OddQ[n] == True, 0, (2^(n/2))]

Table[c[n], {n, 0, 23}]

Clear[d, n];

    
d[n_] := 3*(2^n)

Table[d[n], {n, 0, 23}]

Clear[e, n];

    
e[n_] := 15 - n*7

Table[e[n], {n, 0, 23}]

Clear[f, n];
f[1] = 3;

    
f[n_] := f[n] = n + f[n - 1]

Table[f[n], {n, 1, 23}]

Clear[g, n];

    
g[n_] := 2*(n^3)

Table[g[n], {n, 1, 23}]

Clear[h, n];

    
h[n_] := n! + 1

Table[h[n], {n, 1, 23}]

Exercise 10

Clear[a, n]; 

a[1] = 3;  

a[n_] := a[n] =  (2 n  - 1) + a[n - 1]

Table[a[n], {n, 1, 23}]

Clear[b, n]; 

b[n_] := 7 + n*4

Table[b[n], {n, 0, 23}]

Clear[c, n]; 

c[n_] :=  BaseForm[n, 2]

Table[c[n], {n, 1, 23}]

Simplify[((((Sqrt[n - 1]) - 1))^2)]

Clear[d, n]; 

d[1] = 1;   d[2] = 2;

d[n_] := d[n] =  
        If[IntegerQ[(Sqrt[n - 1])] == True, 
          d[n - 1] + d[-2 (Sqrt[-1 + n]) + n], d[n - 1]]

Table[d[n], {n, 1, 50}]

Clear[e, n]; 

e[1] = 0;

    
e[n_] := e[n] = 2 + 3*e[n - 1]

Table[e[n], {n, 1, 50}]

Clear[f, n]; 

f[1] = 1;  

f[n_] := f[n] =  (2 n  - 1)*f[n - 1]

Table[f[n], {n, 1, 23}]

This would be hard without the known formula for the repeat sequence

Clear[g, n]; 

g[n_] := Mod[Floor[(1/2) + (Sqrt[2 n])], 2]

Table[g[n], {n, 1, 50}]

Clear[h, n]; 

h[1] = 2;  

h[n_] := h[n] =  h[n - 1]^2

Table[h[n], {n, 1, 7}]

Exercise 32

(a)

Clear[a, n];

    
a[n_] := 3* Floor[n/2] + n -  2 Floor[n/2] + 1

Table[a[n], {n, -12, 12}]

Clear[a, n];

    
a[n_] :=  Floor[3 n/2] + 1

Clear[ai, n];

ai[n_] := n -  Floor[ n/3] - 1

ai[a[13]]

Clear[ai, n];

ai[n_] := Ceiling[2 n/3] - 1

Table[{n, ai[n]}, {n, -12, 12}]

p = 2; q = 3; 
    Table[{n, Ceiling[(p/q) Floor[(q/p) n]]}, {n, -12, 
        12}]

p = 5; q = 7; b = 2; 
    Table[{n, 
        Ceiling[(p/q) (Floor[(q/p) n] + b)] - b}, {n, -12, 
        12}]

p = 5; q = 7; b = 1; 
    Table[(Floor[(q/p) n] + b), {n, 0, 23}]

(b)

Clear[b, n];

    
b[n_] := (((-1))^n) 
        5 (7* Floor[n/12] + Mod[Floor[n/2], 6] + 1)

Table[b[n], {n, 0, 43}]

Table[n + Floor[(n/6)] + 1, {n, -10, 10}]