6️⃣

13.6 Recursion Practice

 

Practice

Prime

Write a method called isPrime which returns true if the given integer is prime and false otherwise. This is similar to the Chapter 11 problem, but this time write your method using recursion.
 
In your main method, include a Scanner so the user can check as many numbers as they want until they enter -1.
 
💡
Note: There are more complex solutions, but this is the fastest one within the scope of this chapter.

Merge Sort (Difficult)!

Code a recursive merge sort algorithm that only uses the given parameter array, and creates no other array in the process.
 
 
⚖️
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.