Since you don't know a priori the number of elements in F, one option is to pass F to your function as a list. You can get the length of the list with #F and you can access its entries with F_0, F_1, etc. Similarly, you can return the quotients in a list{q1,q2,...,qs}. There is a section on lists in the M2 documentation under The Macaulay2 Language -> lists and sequences.