
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you very much, understood my mistakes.
Sorry for the bluntness.
how do i get the number of days in a year and in a month? just by prewriting it? like the month number is if it is January then it is 31, etc.?
what about the year?
how do i get the number of days in a year and in a month? just by prewriting it? like the month number is if it is January then it is 31, etc.?
what about the year?
If you divide it by 4, it's high, the rest is 365.
If divisible by 4, high, the rest 365.
2100 is also divisible by 4, but it's 365
1900 too...
However, there are exceptions... although you can ignore them :)
Here's the code with exceptions, but only for our era. The function returns true if the year is a leap year.
Here is the code with exceptions, but only for our era. The function returns true if the year is a leap year.
Exactly, but I would have done it differently... so if the condition is true, there's no need to do the next check.
Most of the years will come out as false in the first check,
if the year is divisible by 4, then we check if it is divisible by 100, most of the remaining ones are not divisible and it will be true,
if it is divisible, then we check the third condition, whether the year is divisible by 400.
Thus only minimum part of years will be tested for all three conditions (which is statistically insignificant and will not affect performance).
The speed of such a function will tend to the speed of one check, while you have the speed of two checks.
And I think the number of days is better by swiping:
Exactly, but I would do it differently... So if the condition worked, there is no need to do another check.
Most of the years will come out on the first check as false,
if the year is divisible by 4, then we check if it is divisible by 100, most of the remaining years are not divisible and we exit as true,
if it is divisible, then we check the third condition, whether the year is divisible by 400.
Thus only minimum part of years will be tested for all three conditions (which is statistically insignificant and will not affect performance).
The performance of such a function will tend to the speed of one check, while yours will tend to the speed of two checks.
I have settled on