Leap year how to solve it?any ways | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Leap year how to solve it?any ways

How to make leap year divide even

9th Jan 2022, 1:35 PM
Igor Stadnyk
2 Answers
+ 1
Hello Igor Stadnyk first show your attempt
9th Jan 2022, 3:12 PM
MATOVU CALEB
MATOVU CALEB - avatar
+ 1
Igor Stadnyk have you learned about the modulo operator, %, that can tell you whether a number divides evenly? No? Well until then here is an alternative. Compare whether the float division result is equal to the integer division result. if (a/b == Math.floor(a/b)) // evenly divides
9th Jan 2022, 10:02 PM
Brian
Brian - avatar