Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class multiplyBigNumbers {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String input = scan.nextLine();
- int n = Integer.parseInt(scan.nextLine());
- List<Integer> output = new ArrayList<>();
- int b = 0;
- if (n == 0){
- System.out.println(0);
- return;
- }
- for (int i = input.length() - 1; i >= 0; i--) {
- int a = Character.getNumericValue(input.charAt(i)) * n + b;
- b = a / 10;
- int c = a % 10;
- output.add(0, c);
- }
- if (b != 0) {
- output.add(0, b);
- }
- for (Integer integer : output) {
- System.out.print(integer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment