Don't check how the calendar knows that any day is a day

xiaoxiao2021-03-06  14

Don't check how the calendar knows that any day is a day

Author: Liu Su 2004-5-2 1:53:20 blog China (Blogchina.com) text / Ge Minqin

-------------------------------------------------- -------------------------Summary:

The most common formula:

W = [Y-1] [(Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] D

Y Y is the number of years, D is the cumulative day of this day in this year, that is, this day is the first day this year.

It is best to use Caile formula:

W = [C / 4] - 2C Y [Y / 4] [13 * (M 1) / 5] D - 1

C is the number of centuries minus one, Y is the two after the year, M is the month, D is the number of days. In January and February, he was as follows from the previous year and 14 months. At this time, C and Y were taken by the previous year.

[...] in both formulas refers to the integer part of the calculation result. The calculated W is 7, the remainder is a few days. If the remainder is 0, it is Sunday. -------------------------------------------------- -------------------------

The weekly system is an ancient traditional system. It is said that because of the "Bible · Genesis", God took a six-day time to rest in the century and seventh day, so people also arrange their work and life in seven days for a cycle, while Sunday is a break date. From a practical point of view, it is a period of seven days, and the length is also suitable. So although China's traditional work cycle is ten days (such as Wang Bo's "Ten Years" said in the "Tengwang Palace", it refers to the work of officials every 10 days, and the tenth day will be taken. Western weeks system. In daily life, we often encounter problems that we know that one day is the week. Sometimes, we still want to know a day in history. Typically, the effective way to solve this method is to see the calendar, but we will never take a calendar with you at any time, and it is more important to bring a thousand years of thousands of years. If you want to calculate a day in your computer programming, it is more unrealistic to make a thousand years in advance. Is there any formula in this time, from the date of launch this day is the day? The answer is yes. In fact, we are often doing this. Let us give a simple example. For example, I know May 1, 2004 is Saturday, then "World No Tobacco Day" on May 31, 2004 is not difficult to calculate the day. We can take a finger from 1 day to 31 days, while the week, the last can last Monday. In fact, the use of mathematical calculations can not be used. We know that the week is seven days round, so May 1st is Saturday. May 8th after seven days is also Saturday. On the date, 8-1 = 7, is the multiple of 7. Similarly, on May 15th, May 22 and May 29, it is Saturday. The differences between their dates and May 1st are 14, 21 and 28, respectively, and the multiple of 7. So what is May 31? 31-1 = 30, although not 7 multiples, 31 divided by 7, the remainder is 2, this is said that the week on May 31 is two days after May 1st. Two days after Saturday is Monday. This simple calculation tells us a basic idea of ​​the week: First, we must know that a certain day before you want to count, it is the standard for the day, which is equivalent to a calculation. " origin". Second, know how many days between the days and this determined days, with 7 divided the difference in this date, the remainder is the week after the week's week of the day of the day. If the remainder is 0, it means that the two days of the week is the same. Obviously, if this is the day as the "origin" day as Sunday, then the remainder is equal to the day of the week, which is more convenient. But directly calculate the number of days between two days, or it is inexhaustible. For example, between 29 July 1992 and May 1, 2004, it is not possible to calculate it. It consists of three periods: First, the remaining days of the year after July 29, 1982; Second, 1983-2003, all days of the 21st, three, from 2004 New Year's Day to May 1st The number of days. The second paragraph is better, it is equal to 21 * 365 5 = 7670 days, and the reason why adds 5, because there are 5 leap years in this time. The first paragraphs and third paragraphs are more troublesome. For example, in the third paragraph, you need to add the number of days before May, plus the date value, that is, 31 29 31 30 1 = 122 days. . Similarly, the first paragraph needs to add the number of days after July, plus the number of days left in July, a total of 155 days. So the total number of days of the total number of days is 122 7670 155 = 7947 days.

Think carefully, if the date "Original" days is selected as December 31, the first time is a whole year, so that the first time and the second period of time can be calculated, all years The total number is exactly equivalent to the difference between the two days. If the "origin" day is further selected to December 31, 1 year of BC (or December 31, the Astronomer is used by the Astronomer), the total number of this year is exactly the year of the year. After this simplifies, it is only necessary to calculate two times: 1. So many years in the total day; Second, the day when you want is the first few days of this year. Ingenious, in accordance with the annual setting of the Queu, this is reversed, December 31, December 31, is exactly the Sunday, that is, the total number of days that is calculated is except that the remaining number of 7 is exactly the day. So now there is only one: How many leap years in so many years. This needs to be understood by the question rules. We know that the Queen of the question calendar is 365 days, and the leap year is 366 days. The method of asserting is to be added to the year in February in February, but it can be completely removed by 400. Therefore, there are 1600, 2000, 2400 is the year, while 1700, 1800, 1900, 2100 is all in the year. In the first 1 year of BC, it is also a leap year according to the question. Therefore, the number of leap years in the year of all years from the year of 1 year (or AD 0) to a certain day of the year, etc., is equal to [(Y-1) / 4] - [(" Y-1) / 100] [(Y-1) / 400], [...] means only the intensity portion. The first item indicates that the number of years that need to be 4 is 4, the second term indicates that the number of years that need to be removed, and the third representation needs to be added to the number of 400. The reason why Y is to reduce one, so we got the first to calculate a day of the day of the week: W = (Y-1) * 365 [(Y-1) / 4] - [(Y-1) ) / 100] [(Y-1) / 400] D. (1) where D is the cumulative day of this day in this year. The calculated W is the number of daily days before 1 year of BC (or AD 0) to this day, December 31. Use 7, the remainder is a few, this day is the day of the week. For example, we will count May 1, 2004: W = (2004-1) * 365 [(2004-1) / 4] - [(2004-1) / 100] [(2004-1) / 400] (31 29 31 30 1) = 731702, 731702/7 = 104528 ... 6, the remainder is six, indicating that this day is Saturday. This is in line with the facts.

The above formula (1) is very accurate, but the calculated number is too big, it is very inconvenient to use. Think carefully, in fact, the number of Number W in this interval W is just to obtain the remainder after 7. This inspires that we can simplify this W value, just find a smaller number of its remaining number, use the term number in the same way, it is to find a smaller positive integer, which can be used. Calculate the accurate weeks. Obviously, the reason why W is because the first item (Y-1) * 365 in the formula is too big. In fact, (Y-1) * 365 = (Y-1) * (364 1) = (Y-1) * (7 * 52 1) = 52 * (Y-1) * 7 (Y-1 The first item of this result is a multiple of 7, divided by 7 remaining 0, so (Y-1) * 365 divides the remainder of 7 in 7, it is equal to the remainder of Y-1 divided by 7. This relationship can be expressed as: (Y-1) * 365 ≡ Y-1 (MOD 7). Among them, ≡ is the number of symbols in the number, and MOD 7 means that the number of bilates between the 号 is true in the case of using 7-made analog (also). Therefore, it can be used (Y-1) instead (Y-1) * 365, so that we get the famous, and the most common calculation of the formula of the week: W = (Y-1) [Y -1) / 4] - [(Y-1) / 100] [(Y-1) / 400] D. (2) Although this formula is much better, it is not the best formula, because the calculation of cumulative days D is more troublesome. Is it possible to calculate the number of months and the date? The answer is affirmative. Let's observe the number of days in each month, the list is as follows: Month: January 2 March Aproved June 7 September October September December ----------- -------------------------------------------------- -------------- Number of days: 31 28 (29) 31 30 31 30 31 31 30 31 30 31 If the number of days is minus 28 (= 4 * 7), it does not affect W 7 The remainder value. In this way, we get another table: month: January 2 March April May 7, Sep Sep October 11, September --------------- -------------------------------------------------- ------- Remaining days: 3 0 (1) 3 2 3 2 3 3 2 3 2 3 Chinese year accumulation: 3 3 6 8 11 13 16 19 21 24 26 29 Leap year accumulation: 3 4 7 9 12 14 17 20 22 25 27 30 Carefully observe, we will find that the remaining days in the five months of January and February, from March to July, 3, 2, 3, 2, 3; April to December The day value of the month is also 3, 2, 3, 2, 3, just a repetition. In the corresponding cumulative days, the cumulative days in January and the difference in cumulative days in the previous month were reduced.

It is precisely because of this regularity, the cumulative days of the blood year and the leap year can be conveniently expressed in mathematical formulas: ╭ D; (when m = 1) D = {31 D; (when M = 2) (3) ╰ [13 * (M 1) / 5] - 7 (m-1) * 28 D I. (When M ≥ 3) where [...] still said that only the intensity portion is taken; M and D are the month and daily number of days of the days they want; the year i = 0, the leap year i = 1. For the expression of M ≥ 3, it is necessary to explain: [13 * (m 1) / 5] -7 is calculated that the above-mentioned secondary cumulative value is added, plus (m-1) * 28 is The total number of times the month before the month of the day. This is a very clever approach that implements the circulation of 3, 2, 3, 2, and 3 with the computational operation. For example, on May 1, 2004,: d = [13 * (5 1) / 5] - 7 (5-1) * 28 1 1 = 122, this is May 1 Cumulative days in 2004. If we change it, we will be the "13 months" and "14 Up" in January and February, not only in accordance with this formula, but also because it has become a "year" (A total of 14 months), the last day of D, the impact of the weekly year also removed, the formula was simplified: D = [13 * (M 1) / 5] - 7 (M- 1) * 28 D. (3 ≤ M≤14) (4) calculate the formula of the week, and can be further simplified: w = (Y-1) [(Y-1) / 4] - [(Y-1) / 100 ] [(Y-1) / 400] [13 * (M 1) / 5] - 7 (m-1) * 28 D. Because two items of -7 and (m-1) * 28 can be divided by 7, then remove these two items, W is unchanged at 7, the formula becomes: w = (Y-1) [( Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] [13 * (M 1) / 5] D. (5) Of course, pay attention to the last year from March and 14 months in January and February, so in calculating the week of January and February, in addition to M To press 13 or 14, year Y is also reduced. For example, January 1, 2004 is Thursday, with this formula, there is: W = (2003-1) [(2003-1) / 4] - [(2003-1) / 100] [(2003) -1) / 400] [13 * (13 1) / 5] 1 = 2002 500 - 20 5 36 1 = 2524; 2524/7 = 360 ... 4. This is actually consistent.

The formula (5) is already a formula for the week, month, but it is not the most concise, and it has improved methods for the processing of years. Let's use this formula to calculate the week on March 1, the first March of each century, the list is as follows: Year: 1 (401, 801, ..., 2001) 101 (501, 901, ..., 2101) --------- -------------------------------------------------- --------- Week: 4 2 ===================================== ================================ year: 201 (601, 1001, ..., 2201) 301 (701, 1101, ... , 2301) ----------------------------------- --------------------- Week: 0 5 It can be seen that every four centuries, this week is repeated once. If we regard 301 (701, 1101, ..., 2301), we look into -2 (the definition of the remainder in the previous bond, the remainder of 7 is divided, so you can do this. The transformation), then this repeating sequence is exactly a 4, 2, 0, -2, etc. According to this, we can get the following calculation of the formula of the week on March 1, the first century: w = (4 - c mod 4) * 2 - 4. (6) In the formula, c is the number of centuries in the century, and the MOD represents the mode operation, the remainder. For example, for March 1, 2001, C = 20, then: w = (4 - 20 MOD 4) * 2 - 4 = 8 - 4 = 4. Endula (6) into formula (5), transform, available: (Y-1) [(Y-1) / 4] - [Y-1) / 100] [(Y-1) / 400] ≡ (4 - C MOD 4) * 2 - 1 (MOD 7). (7) Therefore, in the formula (5) (Y-1) [(Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] These four items, In calculating the date of the first year of each century, you can use (4 - C MOD 4) * 2 - 1.

This formula is written out: w = (4 - c mod 4) * 2 - 1 [13 * (m 1) / 5] D. (8) With the formula for calculating the date of the first year of each century, the formula for calculating the date on the other year of this century is very easy. Because in a century, the end of 00 is the last year, so there is no need to consider the rules of "one hundred years without interval, four hundred years", only need to consider the rules of "four years". It is easy to simplify the formula (2) by the formula (1). We can easily get a simpler calculation of the formula (5) than the formula (5): w = (4 - c) MOD 4) * 2 - 1 (Y-1) [Y / 4] [13 * (M 1) / 5] D. (9) In the formula, Y is the post-two digits of the year. If you take into account the molding operation is not four computation, we can further rewrite (4 - C MOD 4) * 2 into a expression that contains only four operations. Because the number of centimes decreases C - 4Q MOD 4, there is: R = C - 4Q = C - 4Q R = C, where R is C Mod 4, therefore, there is: R = C - 4Q = C - 4 * [C / 4]. (10) (4 - C MOD 4) * 2 = (4 - C 4 * [C / 4]) * 2 = 8 - 2C 8 * [C / 4] ≡ [C / 4] - 2C 1 (MOD 7). (11) Take the formula (11) (9) to get: w = [C / 4] - 2C Y [Y / 4] [13 * (M 1) / 5] D - 1. (12) This formula is reduced by the number of centuries. The end of the year, the month and the number of days can be calculated, and then the remainder of the day is a few, which means this day is the day. The only thing needs to be changed. Month and February as the previous year from March and 14 months, C and Y are values ​​the previous year. Therefore, it is widely believed that this is the best formula for calculating any day. This formula was first devised by German mathematician Christian Cristian Caile (1822-1899) in 1886, therefore known as the Zeller's Formula. For convenience, [13 * (m 1) / 5] is also often written in [26 * (m 1) / 10]. Now let us count on the week of May 1, 2004, obviously c = 20, y = 4, m = 5, D = 1, in the Caile formula, there are: w = [20/4] - 40 4 1 [13 * (5 1) / 5] 1 - 1 = -15. Note that the negative number cannot be obtained in the concept of the remainder of the habit, and only the remainder of the remainder in the mark. For convenience of calculation, we can add an integral multiple of 7, making it a positive number, such as adding 70, get 55. Remove with 7, Yu 6, this day is Saturday.

This is actually consistent, and the results obtained by the formula (2) are consistent. Finally, it is to be explained that the above formula is considered based on the rules of the Great calendar (Gri Great deletion). For the Confucian calendar, Caile has also launched the corresponding formula is: w = 5 - C Y [Y / 4] [13 * (M 1) / 5] D - 1. (13) This, we finally solved the problem of any day of the week, and the day of the week was finally all. May 2, 2004 [Statement] Blog China publishes this article does not represent its statement or description, but does not constitute any investment advice. Please indicate the source. [This website] http://www.blogchina.com/new/display/30137.html Existing Comments 16 Follow Index: 4478 Print Mode FSC518 in 2004-8-1 21:51:29 Write: Known: In 2004, M-month is the week n, asked 10, after 100 years, 1000 years later, the M month D date after 1000 years is the day?

The above formula (1) is very accurate, but the calculated number is too big, it is very inconvenient to use. Think carefully, in fact, the number of Number W in this interval W is just to obtain the remainder after 7. This inspires that we can simplify this W value, just find a smaller number of its remaining number, use the term number in the same way, it is to find a smaller positive integer, which can be used. Calculate the accurate weeks. Obviously, the reason why W is because the first item (Y-1) * 365 in the formula is too big. In fact, (Y-1) * 365 = (Y-1) * (364 1) = (Y-1) * (7 * 52 1) = 52 * (Y-1) * 7 (Y-1 The first item of this result is a multiple of 7, divided by 7 remaining 0, so (Y-1) * 365 divides the remainder of 7 in 7, it is equal to the remainder of Y-1 divided by 7. This relationship can be expressed as: (Y-1) * 365 ≡ Y-1 (MOD 7). Among them, ≡ is the number of symbols in the number, and MOD 7 means that the number of bilates between the 号 is true in the case of using 7-made analog (also). Therefore, it can be used (Y-1) instead (Y-1) * 365, so that we get the famous, and the most common calculation of the formula of the week: W = (Y-1) [Y -1) / 4] - [(Y-1) / 100] [(Y-1) / 400] D. (2) Although this formula is much better, it is not the best formula, because the calculation of cumulative days D is more troublesome. Is it possible to calculate the number of months and the date? The answer is affirmative. Let's observe the number of days in each month, the list is as follows: Month: January 2 March Aproved June 7 September October September December ----------- -------------------------------------------------- -------------- Number of days: 31 28 (29) 31 30 31 30 31 31 30 31 30 31 If the number of days is minus 28 (= 4 * 7), it does not affect W 7 The remainder value. In this way, we get another table: month: January 2 March April May 7, Sep Sep October 11, September --------------- -------------------------------------------------- ------- Remaining days: 3 0 (1) 3 2 3 2 3 3 2 3 2 3 Chinese year accumulation: 3 3 6 8 11 13 16 19 21 24 26 29 Leap year accumulation: 3 4 7 9 12 14 17 20 22 25 27 30 Carefully observe, we will find that the remaining days in the five months of January and February, from March to July, 3, 2, 3, 2, 3; April to December The day value of the month is also 3, 2, 3, 2, 3, just a repetition. In the corresponding cumulative days, the cumulative days in January and the difference in cumulative days in the previous month were reduced.

It is precisely because of this regularity, the cumulative days of the blood year and the leap year can be conveniently expressed in mathematical formulas: ╭ D; (when m = 1) D = {31 D; (when M = 2) (3) ╰ [13 * (M 1) / 5] - 7 (m-1) * 28 D I. (When M ≥ 3) where [...] still said that only the intensity portion is taken; M and D are the month and daily number of days of the days they want; the year i = 0, the leap year i = 1. For the expression of M ≥ 3, it is necessary to explain: [13 * (m 1) / 5] -7 is calculated that the above-mentioned secondary cumulative value is added, plus (m-1) * 28 is The total number of times the month before the month of the day. This is a very clever approach that implements the circulation of 3, 2, 3, 2, and 3 with the computational operation. For example, on May 1, 2004,: d = [13 * (5 1) / 5] - 7 (5-1) * 28 1 1 = 122, this is May 1 Cumulative days in 2004. If we change it, we will be the "13 months" and "14 Up" in January and February, not only in accordance with this formula, but also because it has become a "year" (A total of 14 months), the last day of D, the impact of the weekly year also removed, the formula was simplified: D = [13 * (M 1) / 5] - 7 (M- 1) * 28 D. (3 ≤ M≤14) (4) calculate the formula of the week, and can be further simplified: w = (Y-1) [(Y-1) / 4] - [(Y-1) / 100 ] [(Y-1) / 400] [13 * (M 1) / 5] - 7 (m-1) * 28 D. Because two items of -7 and (m-1) * 28 can be divided by 7, then remove these two items, W is unchanged at 7, the formula becomes: w = (Y-1) [( Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] [13 * (M 1) / 5] D. (5) Of course, pay attention to the last year from March and 14 months in January and February, so in calculating the week of January and February, in addition to M To press 13 or 14, year Y is also reduced. For example, January 1, 2004 is Thursday, with this formula, there is: W = (2003-1) [(2003-1) / 4] - [(2003-1) / 100] [(2003) -1) / 400] [13 * (13 1) / 5] 1 = 2002 500 - 20 5 36 1 = 2524; 2524/7 = 360 ... 4. This is actually consistent.

The formula (5) is already a formula for the week, month, but it is not the most concise, and it has improved methods for the processing of years. Let's use this formula to calculate the week on March 1, the first March of each century, the list is as follows: Year: 1 (401, 801, ..., 2001) 101 (501, 901, ..., 2101) --------- -------------------------------------------------- --------- Week: 4 2 ===================================== ================================ year: 201 (601, 1001, ..., 2201) 301 (701, 1101, ... , 2301) ----------------------------------- --------------------- Week: 0 5 It can be seen that every four centuries, this week is repeated once. If we regard 301 (701, 1101, ..., 2301), we look into -2 (the definition of the remainder in the previous bond, the remainder of 7 is divided, so you can do this. The transformation), then this repeating sequence is exactly a 4, 2, 0, -2, etc. According to this, we can get the following calculation of the formula of the week on March 1, the first century: w = (4 - c mod 4) * 2 - 4. (6) In the formula, c is the number of centuries in the century, and the MOD represents the mode operation, the remainder. For example, for March 1, 2001, C = 20, then: w = (4 - 20 MOD 4) * 2 - 4 = 8 - 4 = 4. Endula (6) into formula (5), transform, available: (Y-1) [(Y-1) / 4] - [Y-1) / 100] [(Y-1) / 400] ≡ (4 - C MOD 4) * 2 - 1 (MOD 7). (7) Therefore, in the formula (5) (Y-1) [(Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] These four items, In calculating the date of the first year of each century, you can use (4 - C MOD 4) * 2 - 1.

This formula is written out: w = (4 - c mod 4) * 2 - 1 [13 * (m 1) / 5] D. (8) With the formula for calculating the date of the first year of each century, the formula for calculating the date on the other year of this century is very easy. Because in a century, the end of 00 is the last year, so there is no need to consider the rules of "one hundred years without interval, four hundred years", only need to consider the rules of "four years". It is easy to simplify the formula (2) by the formula (1). We can easily get a simpler calculation of the formula (5) than the formula (5): w = (4 - c) MOD 4) * 2 - 1 (Y-1) [Y / 4] [13 * (M 1) / 5] D. (9) In the formula, Y is the post-two digits of the year. If you take into account the molding operation is not four computation, we can further rewrite (4 - C MOD 4) * 2 into a expression that contains only four operations. Because the number of centimes decreases C - 4Q MOD 4, there is: R = C - 4Q = C - 4Q R = C, where R is C Mod 4, therefore, there is: R = C - 4Q = C - 4 * [C / 4]. (10) (4 - C MOD 4) * 2 = (4 - C 4 * [C / 4]) * 2 = 8 - 2C 8 * [C / 4] ≡ [C / 4] - 2C 1 (MOD 7). (11) Take the formula (11) (9) to get: w = [C / 4] - 2C Y [Y / 4] [13 * (M 1) / 5] D - 1. (12) This formula is reduced by the number of centuries. The end of the year, the month and the number of days can be calculated, and then the remainder of the day is a few, which means this day is the day. The only thing needs to be changed. Month and February as the previous year from March and 14 months, C and Y are values ​​the previous year. Therefore, it is widely believed that this is the best formula for calculating any day. This formula was first devised by German mathematician Christian Cristian Caile (1822-1899) in 1886, therefore known as the Zeller's Formula. For convenience, [13 * (m 1) / 5] is also often written in [26 * (m 1) / 10]. Now let us count on the week of May 1, 2004, obviously c = 20, y = 4, m = 5, D = 1, in the Caile formula, there are: w = [20/4] - 40 4 1 [13 * (5 1) / 5] 1 - 1 = -15. Note that the negative number cannot be obtained in the concept of the remainder of the habit, and only the remainder of the remainder in the mark. For convenience of calculation, we can add an integral multiple of 7, making it a positive number, such as adding 70, get 55. Remove with 7, Yu 6, this day is Saturday.

This is actually consistent, and the results obtained by the formula (2) are consistent. Finally, it is to be explained that the above formula is considered based on the rules of the Great calendar (Gri Great deletion). For the Confucian calendar, Caile has also launched the corresponding formula is: w = 5 - C Y [Y / 4] [13 * (M 1) / 5] D - 1. (13) This, we finally solved the problem of any day of the week, and the day of the week was finally all. May 2, 2004 [Statement] Blog China publishes this article does not represent its statement or description, but does not constitute any investment advice. Please indicate the source. 【本 文 网址】

http://www.blogchina.com/new/display/30137.html

Existing comments 16 Focus Index: 4478 Print Mode FSC518 Write in 2004-8-1 21:51:29: Known: 2004 Month D Day is the week n, ask 10, 100 years later, 1000 years later The M month D day after 10,000 years is the day?

The above formula (1) is very accurate, but the calculated number is too big, it is very inconvenient to use. Think carefully, in fact, the number of Number W in this interval W is just to obtain the remainder after 7. This inspires that we can simplify this W value, just find a smaller number of its remaining number, use the term number in the same way, it is to find a smaller positive integer, which can be used. Calculate the accurate weeks. Obviously, the reason why W is because the first item (Y-1) * 365 in the formula is too big. In fact, (Y-1) * 365 = (Y-1) * (364 1) = (Y-1) * (7 * 52 1) = 52 * (Y-1) * 7 (Y-1 The first item of this result is a multiple of 7, divided by 7 remaining 0, so (Y-1) * 365 divides the remainder of 7 in 7, it is equal to the remainder of Y-1 divided by 7. This relationship can be expressed as: (Y-1) * 365 ≡ Y-1 (MOD 7). Among them, ≡ is the number of symbols in the number, and MOD 7 means that the number of bilates between the 号 is true in the case of using 7-made analog (also). Therefore, it can be used (Y-1) instead (Y-1) * 365, so that we get the famous, and the most common calculation of the formula of the week: W = (Y-1) [Y -1) / 4] - [(Y-1) / 100] [(Y-1) / 400] D. (2) Although this formula is much better, it is not the best formula, because the calculation of cumulative days D is more troublesome. Is it possible to calculate the number of months and the date? The answer is affirmative. Let's observe the number of days in each month, the list is as follows: Month: January 2 March Aproved June 7 September October September December ----------- -------------------------------------------------- -------------- Number of days: 31 28 (29) 31 30 31 30 31 31 30 31 30 31 If the number of days is minus 28 (= 4 * 7), it does not affect W 7 The remainder value. In this way, we get another table: month: January 2 March April May 7, Sep Sep October 11, September --------------- -------------------------------------------------- ------- Remaining days: 3 0 (1) 3 2 3 2 3 3 2 3 2 3 Chinese year accumulation: 3 3 6 8 11 13 16 19 21 24 26 29 Leap year accumulation: 3 4 7 9 12 14 17 20 22 25 27 30 Carefully observe, we will find that the remaining days in the five months of January and February, from March to July, 3, 2, 3, 2, 3; April to December The day value of the month is also 3, 2, 3, 2, 3, just a repetition. In the corresponding cumulative days, the cumulative days in January and the difference in cumulative days in the previous month were reduced.

It is precisely because of this regularity, the cumulative days of the blood year and the leap year can be conveniently expressed in mathematical formulas: ╭ D; (when m = 1) D = {31 D; (when M = 2) (3) ╰ [13 * (M 1) / 5] - 7 (m-1) * 28 D I. (When M ≥ 3) where [...] still said that only the intensity portion is taken; M and D are the month and daily number of days of the days they want; the year i = 0, the leap year i = 1. For the expression of M ≥ 3, it is necessary to explain: [13 * (m 1) / 5] -7 is calculated that the above-mentioned secondary cumulative value is added, plus (m-1) * 28 is The total number of times the month before the month of the day. This is a very clever approach that implements the circulation of 3, 2, 3, 2, and 3 with the computational operation. For example, on May 1, 2004,: d = [13 * (5 1) / 5] - 7 (5-1) * 28 1 1 = 122, this is May 1 Cumulative days in 2004. If we change it, we will be the "13 months" and "14 Up" in January and February, not only in accordance with this formula, but also because it has become a "year" (A total of 14 months), the last day of D, the impact of the weekly year also removed, the formula was simplified: D = [13 * (M 1) / 5] - 7 (M- 1) * 28 D. (3 ≤ M≤14) (4) calculate the formula of the week, and can be further simplified: w = (Y-1) [(Y-1) / 4] - [(Y-1) / 100 ] [(Y-1) / 400] [13 * (M 1) / 5] - 7 (m-1) * 28 D. Because two items of -7 and (m-1) * 28 can be divided by 7, then remove these two items, W is unchanged at 7, the formula becomes: w = (Y-1) [( Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] [13 * (M 1) / 5] D. (5) Of course, pay attention to the last year from March and 14 months in January and February, so in calculating the week of January and February, in addition to M To press 13 or 14, year Y is also reduced. For example, January 1, 2004 is Thursday, with this formula, there is: W = (2003-1) [(2003-1) / 4] - [(2003-1) / 100] [(2003) -1) / 400] [13 * (13 1) / 5] 1 = 2002 500 - 20 5 36 1 = 2524; 2524/7 = 360 ... 4. This is actually consistent.

The formula (5) is already a formula for the week, month, but it is not the most concise, and it has improved methods for the processing of years. Let's use this formula to calculate the week on March 1, the first March of each century, the list is as follows: Year: 1 (401, 801, ..., 2001) 101 (501, 901, ..., 2101) --------- -------------------------------------------------- --------- Week: 4 2 ===================================== ================================ year: 201 (601, 1001, ..., 2201) 301 (701, 1101, ... , 2301) ----------------------------------- --------------------- Week: 0 5 It can be seen that every four centuries, this week is repeated once. If we regard 301 (701, 1101, ..., 2301), we look into -2 (the definition of the remainder in the previous bond, the remainder of 7 is divided, so you can do this. The transformation), then this repeating sequence is exactly a 4, 2, 0, -2, etc. According to this, we can get the following calculation of the formula of the week on March 1, the first century: w = (4 - c mod 4) * 2 - 4. (6) In the formula, c is the number of centuries in the century, and the MOD represents the mode operation, the remainder. For example, for March 1, 2001, C = 20, then: w = (4 - 20 MOD 4) * 2 - 4 = 8 - 4 = 4. Endula (6) into formula (5), transform, available: (Y-1) [(Y-1) / 4] - [Y-1) / 100] [(Y-1) / 400] ≡ (4 - C MOD 4) * 2 - 1 (MOD 7). (7) Therefore, in the formula (5) (Y-1) [(Y-1) / 4] - [(Y-1) / 100] [(Y-1) / 400] These four items, In calculating the date of the first year of each century, you can use (4 - C MOD 4) * 2 - 1.

This formula is written out: w = (4 - c mod 4) * 2 - 1 [13 * (m 1) / 5] D. (8) With the formula for calculating the date of the first year of each century, the formula for calculating the date on the other year of this century is very easy. Because in a century, the end of 00 is the last year, so there is no need to consider the rules of "one hundred years without interval, four hundred years", only need to consider the rules of "four years". It is easy to simplify the formula (2) by the formula (1). We can easily get a simpler calculation of the formula (5) than the formula (5): w = (4 - c) MOD 4) * 2 - 1 (Y-1) [Y / 4] [13 * (M 1) / 5] D. (9) In the formula, Y is the post-two digits of the year. If you take into account the molding operation is not four computation, we can further rewrite (4 - C MOD 4) * 2 into a expression that contains only four operations. Because the number of centimes decreases C - 4Q MOD 4, there is: R = C - 4Q = C - 4Q R = C, where R is C Mod 4, therefore, there is: R = C - 4Q = C - 4 * [C / 4]. (10) (4 - C MOD 4) * 2 = (4 - C 4 * [C / 4]) * 2 = 8 - 2C 8 * [C / 4] ≡ [C / 4] - 2C 1 (MOD 7). (11) Take the formula (11) (9) to get: w = [C / 4] - 2C Y [Y / 4] [13 * (M 1) / 5] D - 1. (12) This formula is reduced by the number of centuries. The end of the year, the month and the number of days can be calculated, and then the remainder of the day is a few, which means this day is the day. The only thing needs to be changed. Month and February as the previous year from March and 14 months, C and Y are values ​​the previous year. Therefore, it is widely believed that this is the best formula for calculating any day. This formula was first devised by German mathematician Christian Cristian Caile (1822-1899) in 1886, therefore known as the Zeller's Formula. For convenience, [13 * (m 1) / 5] is also often written in [26 * (m 1) / 10]. Now let us count on the week of May 1, 2004, obviously c = 20, y = 4, m = 5, D = 1, in the Caile formula, there are: w = [20/4] - 40 4 1 [13 * (5 1) / 5] 1 - 1 = -15. Note that the negative number cannot be obtained in the concept of the remainder of the habit, and only the remainder of the remainder in the mark. For convenience of calculation, we can add an integral multiple of 7, making it a positive number, such as adding 70, get 55. Remove with 7, Yu 6, this day is Saturday.

This is actually consistent, and the results obtained by the formula (2) are consistent. Finally, it is to be explained that the above formula is considered based on the rules of the Great calendar (Gri Great deletion). For the Confucian calendar, Caile has also launched the corresponding formula is: w = 5 - C Y [Y / 4] [13 * (M 1) / 5] D - 1. (13) This, we finally solved the problem of any day of the week, and the day of the week was finally all. May 2, 2004 [Statement] Blog China publishes this article does not represent its statement or description, but does not constitute any investment advice. Please indicate the source. 【本 文 网址】

http://www.blogchina.com/new/display/30137.html

Existing comments 16 Focus Index: 4478 Print Mode FSC518 Write in 2004-8-1 21:51:29: Known: 2004 Month D Day is the week n, ask 10, 100 years later, 1000 years later The M month D day after 10,000 years is the day?

IP: 61.145.128. * References and replied this message fsc518 wrote at 2004-8-1 21:51:20: Known: 2004 Month D Day is the week n, ask 10, 100 years later, 1000 years After that, the M month D day after 10,000 years is the day?

IP: 61.145.128. * Quote and replied this message fsc518 wrote at 2004-7-28 16:27:17: Mr. Ge Happy birthday! Mr. Wang Ge is creative, and the population is constantly moving, and the vision of the majority of science enthusiasts will expand the vision of the majority of science enthusiasts.

IP: 218.18.37. * Quote and reply to this message fsc518 wrote at 2004-7-21 19:52:32: Taking Ge Mr. Ge, July 29, 1982 as an example, the formula given by the author: w = [Y / 4] R (Y / 7) -2R (C / 4) m ' D = [82/4] R (82/7) -2R (19/4) 7' 29 = 20 5-2 * 3 5 29 = 53 (divided by more than 7 4) The day of Mr. Zhuge was born on Thursday. W (2004, 7, 29) = 39 (divided by more than 7), the birthday of Zhuge this year is also Thursday. Similarly, Mr. Zhuge next year's birthday is Friday. It should be pointed out that the formula given by the author, just take a slight training, you can use the heart to count - and in most cases, it can be done in most cases (and very difficult) with the Caile formula). Welcome to the criticism. Email: fsc518@126.com. Feng Sizhen July 21, 2004

IP: 218.18.150. * Quote and reply to this message fsc518 wrote at 2004-7-19 9:22:25: If you use the formula given: w = [y / 4] R (Y / 7) - 2R (C / 4) m ' D = [97/4] R (97/7) -2R (19/4) 7' 1 = 24 6-2 * 3 5 1 = 30 (Divided by more than 7 2), July 1, 1997 is Tuesday. Please visit www.tom.com, China Science Expo, www.xilu.com's science forum to read my article "I am a live calendar - the improvement of the Zeller formula" and "N-order (N is A unique constructor of the three-dimensional magic squares is more than the number of ps.). Please contact me, email: fsc518@126.com. [Mentioned in Aulian's masterpiece:] Good text! I have also studied this problem before, but it is not as good as "the most common formula" to give a ugly bar with 1997 ★★★ ip: 61.145.129. * Quote and Reply to this message fsc518 on 2004-7-18 21 : 58: 55 Write: Please search "Science Forum" by www.google.com Www.tom.com or China Science Forum to read the article "You are a living calendar --- to Caile ( The improvement of the formula. " Email: fsc518@126.com, welcome to contact.

IP: 218.18.151. * Quote and replied this message Aulian wrote in 2004-5-9 12:16:28: Good text! I have also studied this problem before, but it is better to "the most common formula" to give an ugly bar to take 97 as an example (1) on July 1, 1997. (2) Eliminate the value of step (1) by 4, only the integer part of the result is retained, and the remainder is not considered. 97/4 = 24 ... 1 (3) Character, find the number of corresponding to July is 0. (4) A number of days and the first three steps, such as 1 97 24 0 = 122. (5) The value obtained with step (4) is removed by 7, and the remainder is retained. Such as 122/7 = 17 ... 3 (6) Character, the corresponding number plus the remainder of the fifth step, such as 0 3 = 3 (7) to investigate the table, the corresponding week attached: Month Table January 1 ( 0) February 4 (3) March 4 Apr 201 May 2 June 5 July $ 3 September 6 October 1 November 4 December 6 Table 1900-1999 0 2000-2099 1 Table 1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday 0 Saturday ★★★★ ip: 218.12.209. * Quote and Reply This message CHINABLOGGER is written in 2004-5-5 14:45:11 : I agree that Dumbo is what I like to do this! When will I come to a reform? look forward to! ★ IP: 210.29.158. * Quote and replied this message Hu Zhao three on 2004-5-5 10:52:18 wrote: Yes, I think a formula is so reasonable to accept it, if our university Mathematics courses can be better. In fact, China's education is the lack of this, try to find this book to see it. This tutorial is a good helper for self-study! Encourage ... ★★★★ ip: 218.75. 208. * Quote and reply to this message newguyer wrote in 2004-5-4 19:19:20: Fun Math, a pity, the people in China is too impetuous, there is no possibility to calm down to learn how to think about the blog China Later, I found that they only like to say IT, and then be careful about politics, never possible to be synthesis. . . . . . . IP: 218.75.131. * Quote and reply to this message www.6pm.com on 2004-5-4 18:58:36 wrote: There is actually a simpler way. I am relieved after reading this article.

IP: 218.79.20. * Quote and reply to this message Dumbo wrote at 2004-5-4 18:17:55: This post is probably a touched place, and people who are supported on 9CBS will be more. There are no few people in the blog in China, so most people don't know what this formula is. Lenovo's WAPI argument before, and found that the Chinese saw something, not to force the technology, but first thought about politics. And people who don't understand, people who understand people are silent, it can be described as Chinese characteristics.

IP: 61.48.32. * Quote and reply to this message Sheng Changyi wrote at 2004-5-3 23:25:02: Why bother is so complicated? Look at the calendar. ★★ ip: 211.141.95. * Quote and reply to this message lumg wrote at 2004-5-2 18:36:44: There is no practical value! Perhaps blowing cows to others can be ★ ip: 211.67.30. * Quote and reply this message ZM118 wrote at 2004-5-2 9:22:23: Is there a calendar? Don't check? IP: 220.187.128. * Quote and replied this message Janada wrote at 2004-5-2 9:02:57: It is better to check the calendar simple! Don't use Google how do you know where you want?

IP: 61.49.99. * Quote and Reply to this message

转载请注明原文地址:https://www.9cbs.com/read-49154.html

New Post(0)