No such thing as a small change | |
PerlMonks |
Re: How do you remember the number of days in each month?by wrog (Friar) |
on Sep 18, 2014 at 00:36 UTC ( [id://1100985]=note: print w/replies, xml ) | Need Help?? |
30+(3+ (3*$_+3)%5 - (3*$_+1)%5)/5
works for March (3) through January (13). Or to put it another way, you add 1 to the month and then multiply by 3 and if subtracting 2 from that crosses through a mod-5 boundary then you have a 30 day month, otherwise you have a 31 day month So May (6*3=18 —→ 16) has 31, while June (21 —→ 19) has 30. Yeah, that's how I remember this.
In Section
Past Polls
|
|