S
S
Sergey Sergey2021-05-08 18:01:45
Java
Sergey Sergey, 2021-05-08 18:01:45

How to understand this code, what do the numbers mean?

// Вычисление дня недели для 1 января
        int week = (year + (year - 1) / 4 + 6) % 7;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BorLaze, 2021-05-08
@Sergei1111

Is it really easier to write a post here than to google it?
For example

D
Dmitry Roo, 2021-05-08
@xez

This is obviously the formula for calculating "the day of the week for January 1st".
Substitute the year, for example 2021 - you get the number 5 - i.e. The first of January this year was on a Friday.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question