What is the code to show me which numbers are even or divisible by 3? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the code to show me which numbers are even or divisible by 3?

I need to know the C # code to show me which ones are even or divisible by 3

4th Mar 2021, 11:57 AM
Camilo Quejada
Camilo Quejada - avatar
2 Answers
+ 4
Use the modulo operator % num % 2 == 0 // true if even false if odd num % 3 == 0 // true if divisible by 3
4th Mar 2021, 12:06 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
You need to find remainder and for that we use modulo operator , if number%3==0: "divisible by 3" if number%2==0: "even number"
4th Mar 2021, 12:06 PM
Abhay
Abhay - avatar