Find Remainder
Welcome to the magical world of mathematics! Today, we're going to learn about remainders. A remainder is what’s left over after division. Imagine you have a group of friendly dragons and you want to share 7 pieces of candy among them equally. But, oh no! There are 5 dragons and when you give each dragon 1 piece, you've used 5 pieces. Now you have 2 pieces left. Those 2 pieces are the remainder!
In Python, you can find the remainder using the % operator. We're going to write a function find_remainder that takes two numbers - the number of items and the number of sharing creatures, and returns how many items are left after sharing them evenly.
Example
find_remainder(10, 3)
- This will return
1because 10 divided by 3 gives 3 whole parts with a remainder of 1.
find_remainder(5, 4)
- This will return
1because 5 divided by 4 gives 1 whole part with a remainder of 1.
find_remainder(20, 5)
- This will return
0because 20 divided by 5 evenly gives 4 parts with no remainder.
Are you ready to help the dragons find out how many candies they have left after sharing? Let's code!
Inputs
Arg 1:
10Arg 2:
3Expected Output
1Actual Output