All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Match The Years (Posted on 2006-01-22)
The days of the week (d.o.w) which are Sunday, Monday, Tuesday,Wednesday,Thursday,Friday and Saturday (in that order) are respectively denoted by the numbers 0,1,2,3,4,5 and 6 . Any given year commencing with a particular d.o.w is assigned that value corresponding to that d.o.w. For example, the value ‘0’ would be assigned to a year commencing with a Sunday.

# A year is defined as ‘Matched’ if the remainder obtained, when the year is divided by 7, corresponds precisely with the value assigned to that particular year. For example, 2003 A.D. is NOT A Matched year since 2003 leaves a remainder of 1 upon division by 7 but January 1,2003 occurred on a Wednesday which is denoted by 3.

Determine the total number of ‘Matched’ years between 1960 A.D. and 2560 A.D.(both years inclusive) in accordance with the Western (Gregorian) Calendar System.

 See The Solution Submitted by K Sengupta Rating: 2.7500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Another Computer Program Solution | Comment 11 of 16 |
```The following bc program

define match(n) {
auto i,d,y,c
scale=0
d=5;y=1959;c=0
for(i=1; i<=n; ++i) {
d=d+1;y=y+1
if(y%4==0)d=d+1
if(y%100==0) d=d-1
if(y%400==0) d=d+1
d=d%7
if(i%7==d) {c=c+1; print y+1," ",}
}
return(c)
}

produced

match(600)
1965 1966 1967 1968 1993 1994 1995 1996 2021 2022 2023 2024 2049 2050 2051 2052
2077 2078 2079 2080 2109 2110 2111 2112 2137 2138 2139 2140 2165 2166 2167 2168
2193 2194 2195 2196 2225 2226 2227 2228 2253 2254 2255 2256 2281 2282 2283 2284
2313 2314 2315 2316 2341 2342 2343 2344 2369 2370 2371 2372 2397 2398 2399 2400
2425 2426 2427 2428 2453 2454 2455 2456 2481 2482 2483 2484 2513 2514 2515 2516
2541 2542 2543 2544 84
```

 Posted by Richard on 2006-01-22 19:28:32

 Search: Search body:
Forums (0)