How is modulo used and how does it determine which team?

Thank you ghcc1932! That explains it.

27 % 4 = X

% is always an integer and always gives as small positive X as possible. % = -6 in this case.

So 27-6*4 = 3.

The problem here is they describe % as the remainder of a division previously, which would be 0.75 in this case, 27/4 = 6.75. That would probably throw an error since its not an integer :wink:

An operator cannot be an integer, it’s an operator. We can use the remainder operator on all numbers, floats or integers. The outcome is the physical remainder of the division.

27 / 4 = 6.75

but .75 is not the remainder. The remainder is 0.75 * 4 => 3.

1 Like

Semantics, the % operator has several qualities one of them being that of an integer and it is represented by an integer in the correct equation I gave. I am not a programmer neither a mathematician but is not 0.75 what is left after you remove the integer 6 from 6.75. Does remainder have another meaning here?

I would argue it has but one purpose… return the remainder from any division.

>>> 4.67 % 3
1.67
>>> 
      6
  ------
4 )  27
   - 24   => 6 * 4
   ====
      3   => Remainder

When we extract the decimal fraction from the quotient, 6.75 and multiply it by the divisor we get the remainder (modulo).

0.75 * 4  == 3

Put differently,

4 ( 6 + 0.75 )
=> 4 * 6 + 4 * 0.75
=> 24 + 3
== 27

      6.75
  ---------
4 )  27.00
   - 24   
   =====
      30  
   -  28   
   ======
       20
   -   20
      ====
        0
1 Like

Thanks for clearing that logic up.

possibile methods given here:

Thank you all. Even though i am not 100% clear, i have a fair idea and i beleive it will get better as we move forward. I am a beginner with not computer or solid arithmetic background.

It is not your team number, it is what number you are in your team of four, it’s telling you if you are the 1st one, 2nd one, 3rd one, or the 4th one in your team.

There are only 4 teams. Each person counts off. We know there are at least 27 people in line since the lesson says we get number 27. 27 % 4 = 3, so we are on the third team.

First team: [1, 5, 9, 13, 17, 21, 25] ##any of these numbers % 4 = 1
Second team: [2, 6, 10, 14, 18, 22, 26] ##any of these numbers % 4 = 2
Third team: [3, 7, 11, 15, 19, 23, 27] ##any of these numbers % 4 = 3
Fourth team: [4, 8, 12, 16, 20, 24, 28 ] ##any of these numbers % 4 = 0

Take any of the numbers from any team, and perform the modulo operation, and you’ll confirm that they are on the correct team.

In this case being number 27, we are the 7th person selected for the third team.

1 Like

As other mentioned maybe 3er question need some review so everyone will understand better what to operates.

There are 2 easy ways to divide a team:

  1. With a specific total number (the more used one, this is why people was asking for the total number)
	Total = 40 (example of total number)
	Team size = 4

	40 / 4 = 10 teams (each team with 4 people)
  1. Without a specific total number (using some logic)
	Total = Unknow (as much we know I'm number 27 and there is one more next to me so at least 28)
	Team size = 4
In this case, every people will be assigned in order:
	1st people = 1 % 4 = 1
	2nd people = 2 % 4 = 2
	3rd people = 3 % 4 = 3
	4th people = 4 % 4 = 0
	5th people = 5 % 4 = 1
	6th people = 6 % 4 = 2
	...
	...
	26th people = 26 % 4 = 2 <<<<<<< Answer for 26th people > Team 2
	27th me = 27 % 4 = 3 <<<<<<< I'm in Team 3
	28th people = 28 % 4 = 0 <<<<<<< Answer for 28th people > Team 0
Team numbers:
Team 1
Team 2
Team 3
Team 0

It seems like not a human being who set these questions.

As far as I know, a number is divisible by another one if the division is exact (no remainder). Thus, modulo operator is just perfect for that matter. If the result of modulo operation is zero, that number is divisible.

As for the actions every nth-time, inside a for loop, using an if statement with your counter variable and the modulo operator allows you to perform actions every nth-time.

For example, doing whatever every 4th character in a string:

counter = 0
for i in random_string :
    if counter % 4 == 0 :
        _do_whatever_
    counter += 1

Anyone correct me if I’m wrong, please!

that someone stopped my head from explosion thanks for sharing! @ghcc1932

I did’t understand this and then i saw mod 1 and knew what i had to do. Thanks

1 Like

definitely not a good example lol

LOL that was hilarious

Thank you for even complicating it further lol

Finally an answer which makes sense. I don’t think the wording was very clear and I am native English.
There was nothing saying whether you were in the group or external and when it says “you get 27” I interpreted it to mean “you find there are 27 people in total”
Your explanation should be top of the list.