TOPIC
Runtime Error
mcaja0 asked 4 years ago
Runtime error no compilador do URI, mas em outros funciona normalmente
import java.util.Scanner;
public class Main {
public static int retornaFib(int number) {
if (number == 0) {
return 0;
}
else if(number == 1 || number == 2) {
return 1;
}
else {
return retornaFib(number - 1) + retornaFib(number - 2);
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNext()) {
System.out.println(retornaFib(retornaFib(scan.nextInt())) % scan.nextInt());
}
scan.close();
}
}
This topic has not been answered yet. Be the first!