5/8 of the students in my class were boys.

When 6 girls joined the class, the number of boys equaled the number of girls.
How many students were in my class then?

"What's the formula for this problem?"

b = (5/8) s

so
g = (3/8) s
now g = (3/8) s + 6
and number of students = s + 6

b = 5/8 s = (3/8)s +6
so
(2/8)s = 6
s = 24

that was original s
s+6 = new total = 30

To solve this problem, we don't necessarily need a specific formula. We can use a simple approach to find the solution.

Let's begin by assuming the total number of students in your class is represented by "x."

Given that 5/8 of the students were boys, we can calculate the number of boys in the class as (5/8) * x.

When 6 girls join the class, the number of boys becomes equal to the number of girls. Therefore, we have the equation:

(5/8) * x = (x - (5/8) * x) + 6

Let's solve this equation step by step:

Step 1: Distribute (5/8) to both terms on the right side:

(5/8) * x = x - (5/8) * x + 6

Step 2: Combine like terms on the right side:

(5/8) * x = (8/8) * x - (5/8) * x + 6

Step 3: Simplify fractions:

(5/8) * x = (3/8) * x + 6

Step 4: Subtract (3/8) * x from both sides:

(5/8) * x - (3/8) * x = 6

Step 5: Combine like terms on the left side:

(2/8) * x = 6

Step 6: Simplify fractions:

(1/4) * x = 6

Step 7: Multiply both sides by 4 to isolate x:

x = 4 * 6

x = 24

So, there were 24 students in your class when 6 girls joined.