PracticeMath

Warehouse Seal Suffix

Easy/MediumMathaccumulationstate trackingmodular arithmetic Time not estimated Not started

Context

A warehouse assigns a seal value to a shipment batch. Starting with 1, the seal value is multiplied by every whole number from 1 through the batch size. The warehouse only records the final two decimal digits, so the full product is never needed.

Problem

Write a function that returns the final two decimal digits of the warehouse seal value for a batch containing shipment_count shipments. The seal value is the product of all integers from 1 through shipment_count. For a batch of size zero, use the standard empty-product rule: its value is 1. Return the result as an integer from 0 through 99, preserving the numeric meaning of the two-digit suffix. Reduce the running product modulo 100 after every multiplication. Once the shipment count is large enough that the factorial is divisible by 100, the answer remains 0 for every larger count; handle that case without constructing a large factorial.

Examples

Example 1
Input: shipment_count = 0
Output: 1
Explanation: For shipment_count 0, the executed function returned 1, matching the empty-product rule; the final residue and result_value were both 1. (fact_ids:,, )
Example 2
Input: shipment_count = 5
Output: 20
Explanation: For shipment_count 5, the executed function finished with residue 20 and returned 20. (fact_ids:, )
Example 3
Input: shipment_count = 10
Output: 0
Explanation: For shipment_count 10, the executed function returned 0, and its final result_value was 0. (fact_ids:, )

Constraints

  • 0 <= shipment_count <= 1000000000
  • Types: shipment_count is int; result is int

Function signature

def warehouse_seal_suffix(shipment_count: int) -> int
shipment_count int
The nonnegative number of shipments in the batch.
returns int
The factorial of shipment_count modulo 100, representing the batch seal's final two decimal digits.

Adapted from MBPP problem task_692 (CC BY 4.0). Rewritten, extended and verified by Iksha.

Approved · cb056-abs_92_v214 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1