Question: Java please Write a recursive function that will find the largest triangular number less than or equal to the given target. The triangular numbers are
Java please

Write a recursive function that will find the largest triangular number less than or equal to the given target. The triangular numbers are as follows: 1=13=1+26=1+2+310=1+2+3+415=1+2+3+4+521=1+2+3+4+5+6etc. The series begins with 1 (the first triangular number). To calculate the nth triangular number, n added to the previous triangular number. For example, the fourth triangular number is calculated by adding 4 to the third triangular number (which is 6 ), i.e. 10=(1+2+3)+4. For example, the following statements would lead to the underlined output: Example 1: System.out.println( getLargestTN( 1,0,1) ); 1//1 is the largest triangular number that is less than or equal to 1 Example 2: System.out.println( getLargestTN( 1,0,7) ); 6 //6 is the largest triangular number that is less than or equal to 7 Example 3: System.out.println( getLargestTN( 1,0,25) ); 21 // 21 is the largest triangular number that is less than or equal to 25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
