You are viewing a single comment's thread. Return to all comments →
This is not a case for recursion at all. The below code in Java will solve without any recursion being used.
import java.math.*; public class Solution { public static void main(String[] args) { String arr[] = new Scanner(System.in).nextLine().split("[ ]"); int output = (Integer.parseInt(arr[1])*new BigInteger(arr[0]).remainder(new BigInteger("9")).intValue())%9; System.out.println(output == 0 ? 9:output); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
This is not a case for recursion at all. The below code in Java will solve without any recursion being used.