|Re: Another math challenge...|
Message #2 Posted by Valentin Albillo on 15 Nov 2006, 7:06 a.m.,
in response to message #1 by Olivier TREGER
If I understand the problem correctly, as soon as you reach December 26th, all the zillions and zillions of insects, say N, get multiplied by 26, which happens to be a multiple of 13, and then 12 is added, as December is the 12th month, so you then have:
new N = N * 26 + 12
which, obviously, leaves a reminder of 12 modulo 13. Afterwards there are just five additional days (27, ..., 31), and
computing the reminders modulo 13, in the HP-71B right from the keyboard, you get:
N=12 @ FOR D=27 TO 31 @ N=MOD(N*D+12,13) @ NEXT D @ N [ENTER]
so there will be just 12 insects in the lonesome group.
Even if you wouldn't come up with the December,26th shortcut, the following 3-line HP-71B program solves it trivially:
1 DESTROY ALL @ OPTION BASE 1 @ DIM L(12) @ READ L @ N=2004
2 DATA 31,29,31,30,31,30,31,31,30,31,30,31
3 FOR M=1 TO 12 @ FOR D=1 TO L(M) @ N=MOD(N*D+M,13) @ NEXT D @ NEXT M @ PRINT N
Best regards from V.
Edited: 15 Nov 2006, 7:21 a.m.