<<DiscreteMath`Combinatorica`

Ex 11

2^8

Ex 12

Sum[2^k, {k, 0, 6}]

Ex 15

26^4 + 26^3 + 26^2 + 26^1 + 1

Ex 16

26^4 - 25^4

Ex 17

Inclusion-exclusion

128^5 - 127^5

Ex 18

(a)

Floor[(1000/7)]

(b)

Floor[(1000/11)]

Floor[(1000/(7 11))]

142 - 12

\(Length[
      Select[Range[999], 
        And[IntegerQ[#\/7], Not[IntegerQ[#\/11]]] &]]\)

(c)

Floor[(1000/(11*7))]

(d)

Floor[(1000/11)] + Floor[(1000/7)] - Floor[(1000/(11*7))]

(e)

Floor[(1000/11)] + Floor[(1000/7)] - 2 Floor[(1000/(11*7))]

(f)

999 - (Floor[(1000/11)] + Floor[(1000/7)] - 
          Floor[(1000/(11*7))])

(g)

90 - 
      9  (* two digit numbers *)   +  9*9*8  (* three digit numbers *)

Length[
        Select[Table[k, {k, 100, 999}], 
          And[Length[Union[IntegerDigits[#]]] > 2] &]] + 
      Length[Select[Table[k, {k, 10, 99}], 
          And[Length[Union[IntegerDigits[#]]] > 1] &]]

(h)

Length[
        Select[Table[k, {k, 100, 999}], 
          And[Length[Union[IntegerDigits[#]]] > 2, EvenQ[#]] &]] + 
      Length[Select[Table[k, {k, 10, 99}], 
          And[Length[Union[IntegerDigits[#]]] > 1, EvenQ[#]] &]]

8*8*4  (* three digits ending with 2, 4, 6, 
        8 *)  +9*8  (* 
        three digits ending with 0 *)  + 8*4  (* two digits ending with 2, 4, 6, 8 *) +9  (* 
        two digits ending with 0 *)

Length[
        Select[Table[k, {k, 100, 999}], 
          And[Length[Union[IntegerDigits[#]]] > 2, OddQ[#]] &]] + 
      Length[Select[Table[k, {k, 10, 99}], 
          And[Length[Union[IntegerDigits[#]]] > 1, OddQ[#]] &]]

8*8*5      +  8*5

Ex 19

(a)

105/7

994/7

142 - 15 + 1

(b)

450

(c)

9

(d)

100/4

996/4

249 - 25 + 1

900 - 225

(e)

(999 - 102)/3 + 1

996/12 - 108/12 + 1

300 + 225 - 75

(f)

450

(g)

300 - 75

(h)

75

21

(a)

10^3 - 10

(b)

5*10*10

(c)

9 + 9 + 9

23

3^50

25

26*26*10000 + 100*26^4

27

(26 26  + 26^3) (100  + 1000)

29

(a)

Length[CharacterRange["a", "z"]]

\(Length[
      Complement[
        CharacterRange["a", "z"], {"a", "e", "i", "o", "u"}]]\)

21^8

(b)

21 20 19 18 17 16 15 14

(c)

5 26^7

(d)

5 25 24 23 22 21 20 19

(e)

26^8 - 21^8

(f)

Where is vowel? 1, 2, 3, 4, 5, 6, 7, 8

8*5*21^7

(g)

Start with x

26^7

Start with x no vowels

21^7

26^7 - 21^7

(h)

26^6 - 21^6

31

(a)

0

(b)

5!

(c)

6 5 4 3 2

(d)

7 6 5 4 3

33

(a)

If  n = 1, then 2.

If  n = 2, then 2.

If n > 2, none

(b)

If  n = 1, then 1.

If  n = 2, then 1.

If n > 2, (2^(n - 2))

(c)

If  n = 1, then 0.

If  n = 2, then 2.

If n > 2, then 2(n-1).

37

If  n  is even, then 2^(n/2). If  n  is odd, then 2^((n+1)/2). The common answer is 2^Ceiling[n/2].

38

(a)

9*8*7*6*5*6

9*8*7*6*5*6

(b)

10*9*8*7*6*5

8*7*6*5*4*3

10*9*8*7*6*5 - 8*7*6*5*4*3   (* 
          at least one of b or g *)

2 * 90720-131040

50400    + (90720 - 
          50400 )     + (90720 - 50400 )     + 20160

(c)

(90720 - 50400 )     + (90720 - 50400 )

39

(a)

2*5!

(b)

6! - 2*5!

(c)

((6!)/2)

41

2^7 + 2^8 - 2^5

42

The number of strings with exactly 5 consecutive 0s

e5 = ((2^4)) + ((2^3)) + ((2^3)) + ((2^3)) + ((2^3)) + 
        (2^4)

The number of strings with exactly 6 consecutive 0s

e6 = ((2^3)) + ((2^2)) + ((2^2)) + ((2^2)) + 
        (2^3)

The number of strings with exactly 7 consecutive 0s

e7 = ((2^2)) + ((2^1)) + ((2^1)) + (2^2)

The number of strings with exactly 8 consecutive 0s

e8 = ((2^1)) + ((2^0)) + ((2^1))

The number of strings with exactly 9 consecutive 0s

e9 = ((2^0)) + ((2^0))

The number of strings with exactly 10 consecutive 0s

e10 = 1

The number of strings with at least 5 consecutive 0s

e5 + e6 + e7 + e8 + e9 + e10

The number of strings with at least 5 consecutive 1s is the same

The number of strings with at least 5 consecutive 0s or at least 5 consecutive 1s

2 (e5 + e6 + e7 + e8 + e9 + e10) - 2

Total

(2^10)

Length[
      Select[Strings[{0, 1}, 10], 
        Max[Map[Length, Split[#]]] > 4 &]]

43

Total

2^8

Exactly three consecutive 0s

(* start with 0001,  
      exclude the string end with 0000 *) 
   (* all with 10001 *) 
  (* 
      end with 1000,  
      exclude the string start with 0000 *) 
  (* one s in 1  st and 2  nd,  one s in 2  nd and 3  rd,  
      one s in 1  st and third *)

ne3 = (((2^4) - 
              1)) +(((2^3)) + (2^3) + (2^3) + ((2^3)))+(((2^4) - 1))-3

Length[
      Select[Strings[{0, 1}, 
          8], (Max[
                Map[Length, 
                  Select[Split[#], First[#] == 0 &]]] == 
              3) &]]

Exactly four consecutive 0s

ne4 = (2^3) + (2^2) + (2^2) + (2^2) + (2^3)

Length[
      Select[Strings[{0, 1}, 
          8], (Max[
                Map[Length, 
                  Select[Split[#], First[#] == 0 &]]] == 
              4) &]]

Exactly five consecutive 0s

ne5 = (2^2) + (2^1) + (2^1) + (2^2)

Exactly six consecutive 0s

ne6 = 2 + 1 + 2

Exactly seven consecutive 0s

ne7 = 1 + 1

Exactly eight consecutive 0s

ne8 = 1

ne3 + ne4 + ne5 + ne6 + ne7 + ne8

(ne4 + ne5 + ne6 + ne7 + ne8)

(ne3 + ne4 + ne5 + ne6 + ne7 + ne8) + (ne4 + ne5 + ne6 + ne7 + 
          ne8)

Eight strings are in both:

{0, 0, 0, 1, 1, 1, 1, 0}

{0, 0, 0, 1, 1, 1, 1, 1}

{0, 0, 0, 0, 1, 1, 1, 1}

{1, 0, 0, 0, 1, 1, 1, 1}

{1, 1, 1, 1, 0, 0, 0, 0}

{1, 1, 1, 1, 0, 0, 0, 1}

{1, 1, 1, 1, 1, 0, 0, 0}

{0, 1, 1, 1, 1, 0, 0, 0}

(ne3 + ne4 + ne5 + ne6 + ne7 + ne8) + (ne4 + ne5 + ne6 + ne7 + 
          ne8) - 8

Map[{Length[#], First[#]} &, Split[{0, 0, 0, 1, 0}]]

(Max[Map[Length, Select[Split[#], First[#] == 0 &]]] > 
            2) &[{0, 0, 0, 1, 0}]

Length[
      Select[Strings[{0, 1}, 
          8], (Max[Map[Length, Select[Split[#], First[#] == 0 &]]] > 
              2) &]]

Length[
      Select[Strings[{0, 1}, 
          8], (Max[Map[Length, Select[Split[#], First[#] == 1 &]]] > 
              3) &]]

Length[
      Select[Strings[{0, 1}, 8], 
        Or[(Max[Map[Length, Select[Split[#], First[#] == 0 &]]] > 
                2), (Max[
                  Map[Length, Select[Split[#], First[#] == 1 &]]] > 
                3)] &]]

Length[
      Select[Strings[{0, 1}, 8], 
        And[(Max[Map[Length, Select[Split[#], First[#] == 0 &]]] > 
                2), (Max[
                  Map[Length, Select[Split[#], First[#] == 1 &]]] > 
                3)] &]]

Select[Strings[{0, 1}, 8], 
      And[(Max[Map[Length, Select[Split[#], First[#] == 0 &]]] > 
              2), (Max[
                Map[Length, Select[Split[#], First[#] == 1 &]]] > 
              3)] &]

No consecutive 0s

Length[
      Select[Strings[{0, 1}, 
          8], (Max[Map[Length, Select[Split[#], First[#] == 0 &]]] < 
              2) &]]

Table[
      Length[Select[
          Strings[{0, 1}, 
            k], (Max[
                  Map[Length, Select[Split[#], First[#] == 0 &]]] < 
                2) &]], {k, 1, 15}]

At most consecutive 00s

Length[
      Select[Strings[{0, 1}, 
          8], (Max[Map[Length, Select[Split[#], First[#] == 0 &]]] < 
              3) &]]

Table[
      Length[Select[
          Strings[{0, 1}, 
            k], (Max[
                  Map[Length, Select[Split[#], First[#] == 0 &]]] < 
                3) &]], {k, 2, 15}]

Clear[sol, n];

    
sol[2] = 4; sol[3] = 7; sol[4] = 13;
sol[n_] := sol[n] = 
        sol[n - 1] + sol[n - 2] + sol[n - 3]

Table[sol[k], {k, 2, 15}]

Solve[(x^2) - x - 1 == 0, x]

{r1, r2, r3} = 
      Simplify[x /. Solve[(x^3) - (x^2) - x - 1 == 0, x]]

r1

Simplify[Im[x /. Solve[(x^3) - (x^2) - x - 1 == 0, x]]]

nn = 2; 
    Chop[NSolve[{x (r1) + y (r2) + z (r3) == 7, 
          x (((r1))^2) + y (((r2))^2) + z (((r3))^2) == 13, 
          x (((r1))^0) + y (((r2))^0) + z (((r3))^0) == 4}, {x, y, 
          z}]]

Chop[
      Table[(x (((r1))^k) + y (((r2))^k) + 
              z (((r3))^k)) /. {x -> 3.8479711061989845`, 
            y -> 0.07601444690050753` + 
                0.011318308963751147` I, 
            z -> 0.07601444690050753` - 
                0.011318308963751146` I}, {k, 0, 
          12}]]