I am writing a Math World story where the first numbers are 0-100 and the rest are given birth to. I am trying to assign them genders and this has worked so far:

0 is male

1 is female

2 is male

3 is female

4 is hermaphroditic(male and female at the same time) because it has 1 and 2 as well as itself as factors and there is a 50/50 ratio between male factors and female factors in this case

5 is male

I was just assigning them without much of a function but as you can see I am alternating genders with the primes.

I want to make 2 functions that do 2 things.

1) I want to make a function that alternates gender with each prime

2) I want to make a function that does all these comparisons:

male factors > female factors = male

female factors > male factors = female

female factors = male factors = hermaphroditic

for composite numbers including 1 but not itself as a factor.

I realize I might have to nest these in a trial division primality test and I might need to do several iterations so that I get factors of factors of factors... but still if I could make a program that finds all the factors including primes of a number and than do either the alternating if it is prime or the comparison if composite to assign genders of numbers between 0 and 100 that would be nice.

I originally posted something about this on a forum about excel but realized that I could really only give a really good guess if I didn't have a good program that could do iterations of the factorization process. 1 of the questions that I have is how can I make the factorization only happen when some variable x is composite and if I need to do another iteration take those factors I got and run them through the primality test again to see if any are composite and get the factors of any composite factors.

Also how can I make a function that alternates gender with each prime number in sequence like 2 is male, 3 is female, 5 is male, 7 is female etc. when x in the primality test is prime?