// Scott R. Shannon. 5th October 2019. Java code to produce the sequence A328145 import java.util.ArrayList; public class A328145 { static long MAXVAL = 200; static ArrayList saveCurrent = new ArrayList(); static ArrayList missing = new ArrayList<>(); static long current; public static void main(String[] argv) { saveCurrent.add(0L); saveCurrent.add(1L); saveCurrent.add(1L); saveCurrent.add(2L); saveCurrent.add(3L); int totNumbers = saveCurrent.size(); long biggestCheckValue = saveCurrent.get(totNumbers-1); for (int i=0;i=0) missing.remove(currentIndex); if (current>biggestCheckValue) { for (long i=biggestCheckValue+1;i=missing.get(i)) { current = current - missing.get(i); saveCurrent.add(current); System.out.println(totNumbers+" "+current); ++totNumbers; currentIndex = missing.indexOf(current); if (currentIndex>=0) { missing.remove(currentIndex); if (currentIndex<=i) --i; } continue; } break; } } System.out.println("\nMissing set : "+missing); } }