An analogous day is a date expressed in the mm-dd-yyyy format, where:
yyyy= mm*dd*(sod(mm)+sod(dd))
For example, 09-27-4374 is an analogous day since: sod(mm)+sod(dd)) = 18, so that: yyyy= 9*27*18= 4374.
(i) Determine the respective first and last analogous days in the period covering January 1, 2000 to December 31, 2100 inclusively.
(ii) Determine the total number of analogous days in the period covered under (i).
*** sod(x) refers to the sum of digits of x.
DECLARE FUNCTION sod! (n!)
MO = 1: DA = 1: YE = 2000
GOSUB greg.to.jd
jd1 = jd
MO = 12: DA = 31: YE = 2100
GOSUB greg.to.jd
jd2 = jd
FOR julday = jd1 TO jd2
jd = julday
GOSUB jd.to.greg
IF YE = MO * DA * (sod(MO) + sod(DA)) THEN
ct = ct + 1
PRINT MO; DA; YE
END IF
NEXT
PRINT ct
END
greg.to.jd:
10100 REM :greg mo/da/ye --> jd at noon
10110 GOSUB jul.to.jd
10120 jd = jd + 2 - INT(cw(1) / 100) + INT(cw(1) / 400)
10130 RETURN
jul.to.jd:
10150 REM :jul mo/da/ye --> jd at noon
10160 cw(0) = MO: cw(1) = YE: IF MO < 3 THEN cw(0) = MO + 12: cw(1) = YE - 1
10170 jd = INT(365.25 * cw(1)) + INT(30.61 * (cw(0) + 1)) + DA + 1720995!
10180 RETURN
jd.to.greg:
10200 REM:noon jd-->greg mo/da/ye
10210 cw(0) = INT((jd - 1867216.25#) / 36524.25)
10220 cw(0) = jd + 1 + cw(0) - INT(cw(0) / 4)
10230 GOTO common.from.jd
jd.to.jul:
10240 REM : noon jd-->jul mo/da/ye
10250 cw(0) = jd
common.from.jd:
10260 cw(0) = cw(0) + 1524
10265 cw(1) = INT((cw(0) - 122.1) / 365.25)
10270 cw(2) = INT(365.25 * cw(1))
10275 cw(3) = INT((cw(0) - cw(2)) / 30.6001)
10280 DA = cw(0) - cw(2) - INT(30.61 * cw(3))
10285 YE = cw(1) - 4716
10290 MO = cw(3) - 1: IF MO > 12 THEN MO = MO - 12: YE = YE + 1
10295 RETURN
FUNCTION sod (n)
st$ = LTRIM$(STR$(n))
t = 0
FOR i = 1 TO LEN(st$)
t = t + VAL(MID$(st$, i, 1))
NEXT
sod = t
END FUNCTION
finds
10 25 2000 --- first
7 18 2016
9 15 2025
10 19 2090
5 28 2100
7 30 2100 ---- last
6 is the total number.
|
Posted by Charlie
on 2012-10-04 18:47:41 |