помогите
package com.javarush.task.task30.task3012;
/*
Получи заданное число
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
solution.createExpression(1);
solution.createExpression(1);
solution.createExpression(2);
solution.createExpression(74);
solution.createExpression(1234);
solution.createExpression(3000);
}
public void createExpression(int number) {
int num = number;
System.out.print(num + " =");
ArrayList<Integer> nums = new ArrayList<>();
while (true) {
nums.add(num % 3);
if (num / 3 == 0) {
break;
}
num = num / 3;
}
for (int i = 0; i < nums.size(); i++) {
if (nums.get(i) == 2 && i < nums.size() - 1 && nums.get(i + 1) == (1)) {
System.out.print(" - " + Math.round(Math.pow(3, i)));
System.out.print(" - " + Math.round(Math.pow(3, i + 1)));
System.out.print(" + " + Math.round(Math.pow(3, i + 2)));
i++;
} else if (nums.get(i) == 2 && i < nums.size() - 1 && nums.get(i + 1) == (2)) {
System.out.print(" - " + Math.round(Math.pow(3, i)));
System.out.print(" + " + Math.round(Math.pow(3, i + 2)));
i++;
} else if (nums.get(i) == 2) {
System.out.print(" - " + Math.round(Math.pow(3, i)));
System.out.print(" + " + Math.round(Math.pow(3, i + 1)));
} else if (nums.get(i) == 1) {
System.out.print(" + " + Math.round(Math.pow(3, i)));
}
}
System.out.println();
}
}