A 14-year-old wins award for program that calculates antiprime numbers

Originally published at: A 14-year-old wins award for program that calculates antiprime numbers | Boing Boing

12 Likes

I’ll be 40 this month, and I’ve juuuust about nailed “pants first, then shoes” so, each at our own pace.

13 Likes

Oh shit, really? Are you sure?

7 Likes

One useful lesson I’ve learned from wearing minimalist footwear is that it’s way easier to violate this rule.

8 Likes

You’re onto something…

download

7 Likes

winona-maths-what

6 Likes

That’s why I like minimalist pantwear

6 Likes
4 Likes

I didn’t know this definition. It means that 1 and 2 are highly composite numbers, despite neither being composite…2 is of course prime and 1 is a unit (since it needs to be ignored for unique factoring). I guess fair enough, it feels weird to specifically exclude them, but it’s weird to have them too.

Kudos of course to Sankaran. :slight_smile:

3 Likes

You need some of those pants with the expandable leg holes. It removes the frustration of having to start over when you accidentally start with the shoes.

2 Likes

Oh yeah? Let’s just see what this 14yo has to say about Anti Optimus Prime!

1 Like

Isn’t this how Crisis on Infinite Earths started?

[quote=“DonatellaNobody, post:7, topic:208188, full:true”]

Also: culottes.

2 Likes

Any of yall wanna earn 25 grand for your kid, or maybe just tired of jokes about shoes and pants? Here’s my solution:

import math
# find all antiprimes less than <limit>
def find_antiprimes(limit):
    # list of primes
    primes = []
    # dictionary of composite numbers and their factors:
    #   {n: {2: <power of two>, 3: <power of three>, etc}, etc}
    composites = {}
    factor_count = 0
    antiprimes = {}
    for n in range (2, limit):
        # factorize n
        if len(primes) == 0:
            primes.append(n)
            composites[n] = {n: 1}
        else:
            for p in primes:
                # if no divisors found by p > sqrt(n), n is a prime
                if p > math.sqrt(n):
                    primes.append(n)
                    composites[n] = {n: 1}
                    break
                if n % p == 0:
                    # n == p * d
                    composites[n] = {}
                    d = int(n/p)
                    # copy the factor dictionary
                    for c in composites[d]:
                        composites[n][c] = composites[d][c]
                    # update the factor count for p
                    if composites[n].get(p) == None:
                        composites[n][p] = 1
                    else:
                        composites[n][p] += 1
                    break
        # count the factors
        factors = 1
        for c in composites[n]:
            factors *= (composites[n][c] + 1)
        if factors > factor_count:
            # antiprime is found
            factor_count = factors
            antiprimes[n] = factors
            print ("antiprime " + str(n) + " has " + str(factors) + " factors.")
1 Like

I work in laboratory automation and I can appreciate the anti-prime nature of 24 / 48 / 96 / 384 / 1536.

1 Like

This topic was automatically closed after 5 days. New replies are no longer allowed.