Skip to content

feat(math): add anti_primes_up_to function for generating anti-prime numbers(highly composite numbers)#180

Open
figurexyang wants to merge 1 commit intoluogu-dev:masterfrom
figurexyang:devdev
Open

feat(math): add anti_primes_up_to function for generating anti-prime numbers(highly composite numbers)#180
figurexyang wants to merge 1 commit intoluogu-dev:masterfrom
figurexyang:devdev

Conversation

@figurexyang
Copy link

@figurexyang figurexyang commented Aug 24, 2025

To solve #167

Implement anti_primes_up_to function that generates anti-prime numbers (highly composite records) within a given range. The function uses a DFS approach to generate candidate numbers by assigning non-increasing exponents to small primes, then identifies record-holders based on divisor counts.

The implementation includes:

A nested _gen_by_exponents helper function to generate candidates with divisor counts Logic to merge candidates with same values keeping maximum tau Selection of record-holding anti-primes in ascending order Also update function list documentation to include the new function.

You can test this_function by run command

print(anti_primes_up_to(2162160)==[1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260, 1680, 2520, 5040, 7560, 10080, 15120, 20160, 25200, 27720, 45360, 50400, 55440, 83160, 110880, 166320, 221760, 277200, 332640, 498960, 554400, 665280, 720720, 1081080, 1441440, 2162160])

…numbers(highly composite numbers)

Implement anti_primes_up_to function that generates anti-prime numbers (highly composite records) within a given range. The function uses a DFS approach to generate candidate numbers by assigning non-increasing exponents to small primes, then identifies record-holders based on divisor counts.

The implementation includes:

A nested _gen_by_exponents helper function to generate candidates with divisor counts
Logic to merge candidates with same values keeping maximum tau
Selection of record-holding anti-primes in ascending order
Also update function list documentation to include the new function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant