FAILURE MAP
← Case archive

FA-5461 / Integer arithmetic / Open access

Arithmetic progression sum · case 01

The last term is multiplied by the count instead of using the endpoint average.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The last term is multiplied by the count instead of using the endpoint average.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return n*(2*a+(n-1)*d)//2

Unsuccessful approach: The final term index is n instead of n minus one.

Case contract

Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. a and d may be signed; n>=0. Sum n terms starting with a and common difference d. Exact operational definition: n*(2*a+(n-1)*d)//2

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, d, n):
    return n*(a+(n-1)*d)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 3, 4)', solve(*(2, 3, 4)), 26)
check('fixture 2: (5, 0, 3)', solve(*(5, 0, 3)), 15)
check('fixture 3: (4, -1, 4)', solve(*(4, -1, 4)), 10)
check('fixture 4: (9, 2, 0)', solve(*(9, 2, 0)), 0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (2, 3, 4)4426Failed
fixture 2: (5, 0, 3)1515Passed
fixture 3: (4, -1, 4)410Failed
fixture 4: (9, 2, 0)00Passed

SHA-256 / 33b65cde83f918b5f1f1e2d691fe23ce956f421559a6eb9fd3b38e808e157079

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, d, n):
    return n*(2*a+n*d)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 3, 4)', solve(*(2, 3, 4)), 26)
check('fixture 2: (5, 0, 3)', solve(*(5, 0, 3)), 15)
check('fixture 3: (4, -1, 4)', solve(*(4, -1, 4)), 10)
check('fixture 4: (9, 2, 0)', solve(*(9, 2, 0)), 0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (2, 3, 4)3226Failed
fixture 2: (5, 0, 3)1515Passed
fixture 3: (4, -1, 4)810Failed
fixture 4: (9, 2, 0)00Passed

SHA-256 / 61ed950c8bd190fedcffc357a0d644b925d70d2d30732d2f8b98dba905c15537

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, d, n):
    return n*(2*a+(n-1)*d)//2
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 3, 4)', solve(*(2, 3, 4)), 26)
check('fixture 2: (5, 0, 3)', solve(*(5, 0, 3)), 15)
check('fixture 3: (4, -1, 4)', solve(*(4, -1, 4)), 10)
check('fixture 4: (9, 2, 0)', solve(*(9, 2, 0)), 0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: (2, 3, 4)2626Passed
fixture 2: (5, 0, 3)1515Passed
fixture 3: (4, -1, 4)1010Passed
fixture 4: (9, 2, 0)00Passed

SHA-256 / 49a787ecf2ac40aa53773f8f9ebd78938e444de09fe96f85c5920a62df4d3e1b

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:49.775448+00:00.

Case digest / 5dfdbb9d59ba6eca1d4a10b3a9069f2c8834e11d0cc674a81853928d19b5661c