Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package baseconversion;
- import java.util.*;
- public class BaseConversion {
- static Scanner input = new Scanner(System.in);
- public static String convert (int num, int b, String total) {
- if (num % b == 0) return total;
- if (num % b > 0) {
- return total + "" + b;
- }
- return convert(num, b, total);
- }
- public static void main(String[] args) {
- String mainTotal = "";
- System.out.println("Input a number");
- int mainNum = input.nextInt();
- System.out.println("Input the base case");
- int mainB = input.nextInt();
- convert(mainNum, mainB, mainTotal);
- System.out.println(mainTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement