Changing $integer to 6 for example gives:
6
5 1
4 2
4 1 1
3 3 1 # oops
3 2 1
3 1 1 1
2 2 2 1 # oops
2 2 1 1
2 1 1 1 1
1 1 1 1 1 1
You can check how many partitions of N exist for the first many values of N at this site. For N=10, for instance, there should be 77 and your script returns less than 50 (many of them even adding up to more than 10).
Update: Other than an extra 1 on a few partitions here and there, it seems to get all of them though.