To figure out what it will take for Donald J. Trump — or Marco Rubio or Ted Cruz — to win the Republican nomination, we built the G.O.P. presidential nomination process in code. This interactive delegate calculator uses each state’s delegate allocation rules, along with estimates of how favorable each district is for each candidate, to simulate how the race might unfold.

Let’s start by assuming Mr. Trump keeps winning …

If Trump has a good showing on Super Tuesday and continues to win afterward — even by small margins — he will most likely win the nomination.

In this scenario, Mr. Trump’s rivals remain strong after a tough Super Tuesday. But they fail to block him from winning the nomination.

Each line in the chart above represents one possible outcome. While Mr. Trump’s average vote total is held to only 32 percent, most of these paths end with him winning a majority of delegates by the convention.

Republican delegate rules are biased toward winners: It's easy to rack up a lot of delegates if you win, even if you win by only a little. That’s especially true starting March 15, when states are allowed to allocate their delegates on a winner-take-all basis. So if Mr. Trump keeps winning, it will be very tough to stop him — even if he earns far less than a majority of the vote.

This doesn’t even count the unbound delegates, roughly 7 percent of the total, who may make the difference between a narrow victory and a brokered convention.

A good showing by Trump on Super Tuesday doesn’t preclude a Rubio comeback.

The same delegate rules that help Mr. Trump win without a majority of the popular vote also make it easier for one of his rivals to mount a comeback.

Mr. Rubio could lose every state on Super Tuesday and still win a majority of delegates. Here’s how:

Mr. Rubio’s path starts with quick exits by Mr. Cruz and Mr. Kasich, giving Mr. Rubio an opportunity to consolidate their support. His challenge would be to do this before March 15, when a slew of big states cast ballots. Florida and Ohio, two winner-take-all states worth a combined 165 delegates, would be especially important.

But if Rubio starts winning after March 15, it may be too late for him to get a majority of delegates.

If Mr. Rubio struggles on Super Tuesday and can’t at least split the delegates on March 15, his campaign will be in trouble. But he still might be able to earn enough votes to force a brokered convention by preventing Mr. Trump from earning an outright majority of delegates.

The G.O.P. has elected a nominee on the first ballot at every convention since 1948, and it would be hard to know what to expect if it failed to do so this year. Mr. Trump might threaten to run as a third-party candidate. Mr. Rubio would hope for the support of many party elders and perhaps many of Mr. Cruz’s delegates, supposing Mr. Cruz has dropped out.

(The rules governing delegates after their pledged candidate drops out vary by state. Some, like Alabama, allow candidates to release their delegates to vote for anyone, but many force delegates to remain bound by their initial pledges.)

Try your own scenario!

Adjust the sliders in the chart below to explore more scenarios. The scenarios presented here do not aim to predict what will happen, because we don’t know what will. But they are theoretically and mathematically possible, and thus help us understand the dynamics of the race to the Republican nomination. Here are some presets to get you started: