FAILURE MAP
← Case archive

FA-5516 / Number theory / Open access

Euler totient · case 01

The prime-only totient shortcut is applied to composite numbers.

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

ROOT CAUSE

The prime-only totient shortcut is applied to composite numbers.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum(math.gcd(k,n)==1 for k in range(1,n+1))

Unsuccessful approach: Numbers that do not divide n can still share a factor with n.

Case contract

Integer inputs; n is positive unless a zero or negative fixture explicitly extends that operation. A modulus is greater than one; p is prime; exponent k may be signed when an inverse exists. Euler totient. Exact operational definition: sum(math.gcd(k,n)==1 for k in range(1,n+1))

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Number theory 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(n):
    return n-1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1,)', solve(*(1,)), 1)
check('fixture 2: (9,)', solve(*(9,)), 6)
check('fixture 3: (12,)', solve(*(12,)), 4)
check('fixture 4: (7,)', solve(*(7,)), 6)
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: (1,)01Failed
fixture 2: (9,)86Failed
fixture 3: (12,)114Failed
fixture 4: (7,)66Passed

SHA-256 / fb7d2b3685240c21bc6b22c59b29355b748e8c4a1f2356979041751acf850fd6

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(n):
    return sum(n%k!=0 for k in range(1,n))+1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1,)', solve(*(1,)), 1)
check('fixture 2: (9,)', solve(*(9,)), 6)
check('fixture 3: (12,)', solve(*(12,)), 4)
check('fixture 4: (7,)', solve(*(7,)), 6)
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: (1,)11Passed
fixture 2: (9,)76Failed
fixture 3: (12,)74Failed
fixture 4: (7,)66Passed

SHA-256 / 23d5761cb4730ea7d2b4d17e4f6175e28a17d1c4e9d807694c87e90826e86104

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(n):
    return sum(math.gcd(k,n)==1 for k in range(1,n+1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1,)', solve(*(1,)), 1)
check('fixture 2: (9,)', solve(*(9,)), 6)
check('fixture 3: (12,)', solve(*(12,)), 4)
check('fixture 4: (7,)', solve(*(7,)), 6)
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: (1,)11Passed
fixture 2: (9,)66Passed
fixture 3: (12,)44Passed
fixture 4: (7,)66Passed

SHA-256 / 467d8f0b905ffe123fafaeb0c57f37bc6c16c78e257107c1903cc5fdf66496ed

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:50.219495+00:00.

Case digest / 7ba3c36444c9f30ddea52b96b98b04926c6318fdcf6a83ab83f9b3bfa1e22aec