Problem Statement

You can create an anagram by changing the order of characters in one word or phrase to create a new word or phrase. While an anagram must use all of the characters, it is useful (and funnier) to use spaces when helpful. For example, one might rearrange the letters of "astronomer" to yield "moon starer".

How many potential arrangements are there in a word like "is"?

How many in a word like "bat"?

Can you write a program that will determine the number of arrangements possible from a given word length?

Details

  • Your program should take the word length as the input and prints the number of ways in which they can be arranged.
  • There is be more than one way to solve this problem.
  • You might use recursion.

Sample Output

Enter the word length : 5 There are 120 possible arrangements.

Curriculum Connections

  • Programming factorials
  • Solving a problem with recursion
  • Contrasting recursive with iterative solutions
  • Anagrams

Solutions

2 ruby

Do NOT follow this link or you will be banned from the site!

Non-profit Tax ID # 203478467