1. Home
  2. Explore
  3. Computer Science
  4. Recursion and Factorials

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Recursion and Factorials

  • 11Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Factorial Basics

For a positive integer nnn, what does n!n!n! represent?

11 questions

  1. 1

    For a positive integer nnn, what does n!n!n! represent?

    1. A

      The product of the integers from nnn down to 111

    2. B

      The product of nnn and the next integer only

    3. C

      The sum of the integers from nnn down to 111

    4. D

      The number of integers from 111 through nnn

    Correct answer
    A

    The product of the integers from nnn down to 111

    Explanation

    The factorial of a positive integer is the product n(n−1)(n−2)⋯3⋅2⋅1n(n-1)(n-2)\cdots 3 \cdot 2 \cdot 1n(n−1)(n−2)⋯3⋅2⋅1.

  2. 2

    What is the value of 4!4!4!?

    1. A

      161616

    2. B

      121212

    3. C

      242424

    4. D

      363636

    Correct answer
    C

    242424

    Explanation

    4!=4⋅3⋅2⋅1=244! = 4 \cdot 3 \cdot 2 \cdot 1 = 244!=4⋅3⋅2⋅1=24.

  3. 3

    What is the value of 2!2!2!?

    1. A

      222

    2. B

      333

    3. C

      444

    4. D

      111

    Correct answer
    A

    222

    Explanation

    2!=2⋅1=22! = 2 \cdot 1 = 22!=2⋅1=2.

  4. 4

    What is the value of 1!1!1!?

    1. A

      222

    2. B

      It is undefined

    3. C

      111

    4. D

      000

    Correct answer
    C

    111

    Explanation

    1!1!1! is the product containing just 111, so its value is 111.

  5. 5

    According to the definition given, what is 0!0!0!?

    1. A

      It equals −1!-1!−1!

    2. B

      It is undefined

    3. C

      111

    4. D

      000

    Correct answer
    C

    111

    Explanation

    0!0!0! is defined to be 111.

  6. 6

    What kind of input is the function fact intended to accept in the example?

    1. A

      Any positive real number

    2. B

      Only positive even integers

    3. C

      A positive integer or zero

    4. D

      Any integer, including negative integers

    Correct answer
    C

    A positive integer or zero

    Explanation

    The example describes fact as taking a positive integer or zero and returning that number's factorial.

  7. 7

    In computer science, what makes a solution recursive?

    1. A

      A function stores every result in a list

    2. B

      A function divides a problem into unrelated tasks

    3. C

      A function calls itself to help solve a problem

    4. D

      A function repeats instructions without calling itself

    Correct answer
    C

    A function calls itself to help solve a problem

    Explanation

    Recursion is a way of solving a problem in which a function calls itself.

  8. 8

    For n≥1n \ge 1n≥1, which relationship expresses a factorial recursively?

    1. A

      n!=(n−1)!n! = (n-1)!n!=(n−1)!

    2. B

      n!=n⋅n!n! = n \cdot n!n!=n⋅n!

    3. C

      n!=n+(n−1)!n! = n + (n-1)!n!=n+(n−1)!

    4. D

      n!=n(n−1)!n! = n(n-1)!n!=n(n−1)!

    Correct answer
    D

    n!=n(n−1)!n! = n(n-1)!n!=n(n−1)!

    Explanation

    For n≥1n \ge 1n≥1, the factors after the initial nnn make up (n−1)!(n-1)!(n−1)!, so n!=n(n−1)!n! = n(n-1)!n!=n(n−1)!.

  9. 9

    Why is the rule n!=n(n−1)!n! = n(n-1)!n!=n(n−1)! not a complete definition of factorials by itself?

    1. A

      At n=0n=0n=0, it refers to (−1)!(-1)!(−1)!, which is undefined

    2. B

      It cannot be applied to any positive integer

    3. C

      It requires factorials to be sums rather than products

    4. D

      It gives the wrong result whenever nnn is greater than 111

    Correct answer
    A

    At n=0n=0n=0, it refers to (−1)!(-1)!(−1)!, which is undefined

    Explanation

    Substituting n=0n=0n=0 gives 0!=0⋅(−1)!0! = 0 \cdot (-1)!0!=0⋅(−1)!, but (−1)!(-1)!(−1)! is not defined. The recursive rule therefore needs a separate base case.

  10. 10

    Which base case completes the recursive definition for factorials of nonnegative integers?

    1. A

      (−1)!=1(-1)! = 1(−1)!=1

    2. B

      0!=10! = 10!=1

    3. C

      0!=00! = 00!=0

    4. D

      1!=01! = 01!=0

    Correct answer
    B

    0!=10! = 10!=1

    Explanation

    The complete definition uses n!=n(n−1)!n! = n(n-1)!n!=n(n−1)! for n≥1n \ge 1n≥1 and the base case 0!=10! = 10!=1.

  11. 11

    Using the recursive rule and the base case, what is 3!3!3!?

    1. A

      666

    2. B

      999

    3. C

      333

    4. D

      121212

    Correct answer
    A

    666

    Explanation

    Apply the rule repeatedly: 3!=3⋅2!=3⋅2⋅1!=3⋅2⋅1=63! = 3 \cdot 2! = 3 \cdot 2 \cdot 1! = 3 \cdot 2 \cdot 1 = 63!=3⋅2!=3⋅2⋅1!=3⋅2⋅1=6.

Question 1 of 11
Question 1 of 11

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent