I already have the code for the assignment below, but the code has an error in the driver class. Please help me fix it. The assignment: Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class. The resource class and the driver class need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code The code of the resource class: import java.util.ArrayList; import java.util.List; public class U10E03R { // Recursive function to // print factors of a number public static void factors(int n, int i) { // Checking if the number is less than N if (i <= n) { if (n % i == 0) { System.out.print(i + " "); } // Calling the function recursively // for the next number factors(n, i + 1); } } } The code of the driver class: public class U10E03D { public static void main(String args[]) { int N = 16; factors(N, 1); } } The error is shown in the picture I attached, please have a look at it.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
I already have the code for the assignment below, but the code has an error in the driver class. Please help me fix it.
The assignment:
Make a recursive method for factoring an integer n. First, find a factor f, then recursively factor n / f. This assignment needs a resource class and a driver class. The resource class and the driver class need to be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code
The code of the resource class:
import java.util.ArrayList;
import java.util.List;
public class U10E03R
{
// Recursive function to
// print factors of a number
public static void factors(int n, int i)
{
// Checking if the number is less than N
if (i <= n) {
if (n % i == 0) {
System.out.print(i + " ");
}
// Calling the function recursively
// for the next number
factors(n, i + 1);
}
}
}
The code of the driver class:
public class U10E03D
{
public static void main(String args[])
{
int N = 16;
factors(N, 1);
}
}
The error is shown in the picture I attached, please have a look at it.
![1 public class U10E03D
2 {
public static void main(String args[])
{
int N = 16;
factors(N, 1);
U9E02R.class
U9E02D.java
U9P08R.java
U9P08D.java
U9P07R.java
| U9P07D.java
U10E03R.java G U10E02R.j
Compile Messages
JGRASP Messages
Run VO Interactions
Stop
L ----JGRASP: operation complete.
----JGRASP exec: javac -g U10E03D.java
U10E03D.java:6: error: cannot find symbol
factors(N, 1);
Clear
Copy
symbol:
method factors(int,int)
location: class U10E03D
1 error
---JGRASP wedge2: exit code for process is 1.
--JGRASP: operation complete.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9662a84a-bfe1-4836-aca1-8bd4583109d9%2Ff2bb49af-eade-4460-a9bc-e2948ff5cfd8%2Fw4czxw_processed.png&w=3840&q=75)

Step by step
Solved in 2 steps with 1 images









