I have cows, horses and dogs, a different prime number of each. If I multiply the number of cows (c) by the total of cows and horses (c+h), the product is 120 more than the number of dogs (d), that is: c*(c+h) = 120 + d.
How many of each do I have?
Thanks, Rod. I noticed that my wording was not clear on that point. I had just written a long reply, trying to respond to your post, but found that got lost when I thought I was submitting it(the usual fate) so I'll try again as a separate comment. I believe I was correct is saying that h must be 2, the only even prime, so I was considering (c,h) as a pair of prime addends, but of course c+2 would not always be a prime. I have been chiding pcbouhid on clarity of specs, and he has obliged in this problem.
I think we can agree 11 is the lowest possible value for c (can't have negative dogs, can we), and hence (11,13) would be the lowest assignments for (c+h) -- which gives 11*13 = 143 = 120 + 23 -- which satisfies the conditions. I have not proved that is the only solution. Charlie uses a double loop to prove that up to the 10,000th prime, but a single loop, with h=2, probably would suffice. That prm(n) function is interesting -- wonder how it is implemented in that language -- a finite internal table, or a rather slow factoring and counting for each call?