St Ives

An old riddle.

As I was going to St Ives,
I met a man with 7 wives,
Every wife had 7 sacks,
Every sack had 7 cats,
Every cat had 7 kits:
Kits, cats, sacks, wives,
How many were going to St Ives?

A reasonable guess is 2752, a sum of the beings the narrator met:

const man   = 1;
total_sacks = wives * sacks;
total_cats  = total_sacks * cats;
total_kits  = total_cats * kits;

first_guess = man + wives + total_cats + total_kits;

And another guess might follow the second to last line more literally and sum 2401 kits, 343 cats, 49 sacks, and 7 wives for an answer of 2800:

second_guess = total_kits + total_cats + total_sacks + wives;

…but the correct answer is 1.

if (solo) {
  travelers = 1;
  verb = 'was';
} else {
  travelers = 2;
  verb = 'were';
}

answer = travelers;