#!/usr/bin/env python3 """Calculate and verify sum of integers 1 to 1000.""" def sum_n(n: int) -> int: """Sum of integers from 1 to n using formula n*(n+1)/2.""" return n * (n + 1) // 2 def verify_sum(expected: int, actual: int) -> bool: """Verify two sums match.""" return expected == actual if __name__ == "__main__": n = 1000 expected = 500500 actual = sum_n(n) is_correct = verify_sum(expected, actual) result = f"Sum of 1 to {n}: {actual}\n" result += f"Expected: {expected}\n" result += f"Verified: {is_correct}\n" print(result) with open("/root/.hermes/wizard-outputs/spark/result.txt", "w") as f: f.write(result)