How do I check if a number is divisible by three?


#1

How do I check if a number is divisible by three? On instruction 4, it says that if the number is divisible by three, it should call the cube of the number. But my question is: How do I even check if a number is divisible by three?


#2

Hey @javapro20754 :slight_smile:

You can check if a number is divisible by 3 using the modulo operator '%'
Like so:

if your_num % 3 == 0:
    your_code

I hope this helps you!! Have a good day.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.