Partition+Class

//Note this class was just slightly modified from the class found here://

http://introcs.cs.princeton.edu/java/23recursion/Partition.java.html public class Partition { private String string_of_partition ="";

Partition {

} public void partition(int n) { partition(n, n, ""); } public void partition(int n, int max, String prefix) { if (n == 0) { this.string_of_partition+=prefix+"\n"; return; }

for (int i = Math.min(max, n); i >= 1; i--) { partition(n-i, i, prefix + " " + i); } } public String getPartition { return string_of_partition; }

public static void main(String[] args) { Partition partition = new Partition; int N = 4; partition.partition(N); System.out.println(partition.getPartition); }

}