(SPOJ) f91 - Solution 2
Two years ago, I solved this problem using the language C (the only solution using C in this blog). You can check the previous solution here . Although the solution could be as simple as: If n <= 100, print 91 If n >= 101, print n-10 This solution calculates the answer through the given recursion, which is: If n <= 100, do f91(n) = f91(f91(n+11) If n >= 101, do f91(n) = n-10 import java.io.*; class Main { public static int f91(int n) { if (n >= 101) { return n-10; } return f91(f91(n+11)); } public static int reader(BufferedReader br) throws NumberFormatException, IOException { ...