Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.
Worked example
// app/register/page.tsx
export default async function PartySizeAllocation({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const { size } = await searchParams;
const n = Math.max(1, Math.min(80, Math.trunc(Number(size) || 1)));
return (
<p>
Reserve {Math.ceil(n / 8)} tables of eight for {n} attendees.
</p>
);
}Implementation notes
Negative party sizes and zero capacity are invalid inputs. Validate them before dividing or rounding up the number of groups.
Try it yourself
Compare an exact capacity multiple with one additional guest.
Open the Next.js example →Editorial date October 13, 2026 · Published December 6, 2026