Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Recursion(Java Language) Write a program named NumberPermutation.java and implem

ID: 3744771 • Letter: R

Question

Recursion(Java Language)

Write a program named NumberPermutation.java and implement a recursive method specified below:
public static void permutation(int num)
This method has a positive integer as its parameter and displays all permutations of the odd digits of that length. Display these values in ascending order. For example, if the length is 3, your program should display:
111 113 115 117 119 131 133 135 ... Recursion(Java Language)

Write a program named NumberPermutation.java and implement a recursive method specified below:
public static void permutation(int num)
This method has a positive integer as its parameter and displays all permutations of the odd digits of that length. Display these values in ascending order. For example, if the length is 3, your program should display:
111 113 115 117 119 131 133 135 ... Recursion(Java Language)

Write a program named NumberPermutation.java and implement a recursive method specified below:
public static void permutation(int num)
This method has a positive integer as its parameter and displays all permutations of the odd digits of that length. Display these values in ascending order. For example, if the length is 3, your program should display:
111 113 115 117 119 131 133 135 ...

Explanation / Answer

public class NumberPermutation { public static void permutation(int num, String str) { if(num == 0) { System.out.println(str); } else { for (int i = 1; i < 10; i += 2) { permutation(num - 1, str + i); } } } public static void permutation(int num) { permutation(num, ""); } public static void main(String[] args) { permutation(3); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote