How to spot them

Take a positive integer k. Find its divisors. Find the distinct prime factors of each divisor. Sum all these factors together. If this number (sum) is a divisor of k (if the sum divides k) then, this number k, is a BIU number


Let's take the number 54
Find all the divisors: [1, 2, 3, 6, 9, 18, 27, 54]
Find the distinct prime factors of each divisor
NOTE: For the case of 1 we take as distinct prime factor 1

1  -> 1  
2  -> 2  
3  -> 3  
6  -> 2,3  
9  -> 3  
18 -> 2,3  
27 -> 3  
54 -> 2,3 

Now we take the sum of all these prime factors
27 divides 54 (leaves no remainder)
So, 54 is a BIU number.

Another (quick) example for k=55
Divisors: [1,5,11,55]
Sum of distinct prime factors: 1+5+11+5+11=33
33 is NOT a divisor of 55, that's why 55 is NOT a BIU number.

BIU numbers

Here are the first 20 of them:

1,21,54,290,735,1428,1485,1652,2262,2376,2580,2838,2862,3003,3875,4221,4745, 5525,6750,7050...

but this list goes on and there are many BIU numbers that are waiting to be descovered by you!

The Challenge

Given an integer n>0 as input, output the nth BIU number

Test Cases



This is .Shortest answer in bytes wins!

  • 2
    \$\begingroup\$ But 1 is not prime... \$\endgroup\$ – Stephen Sep 27 '17 at 0:38
  • 3
    \$\begingroup\$ @Stephen thats why I said "For the case of 1 we take as distinct prime factor 1". This is my challenge and this is one of the rules of this challenge.I didn't say that 1 is prime. \$\endgroup\$ – user72253 Sep 27 '17 at 0:42
  • 4
    \$\begingroup\$ Why are the numbers called "BIU"? \$\endgroup\$ – Misha Lavrov Sep 27 '17 at 1:08
  • 4
    \$\begingroup\$ I'm not sure but I think that it has to do with bisexual intellectual unicorns using them in their everyday life (not in our universe of course...) \$\endgroup\$ – user72253 Sep 27 '17 at 1:13
  • 5
    \$\begingroup\$ Downvoters, don't be shy. Share your thoughts with the rest of us. \$\endgroup\$ – user72253 Sep 27 '17 at 13:17

Jelly, 16 15 bytes


Try it online!

Woohoo for builtins (but they mysteriously hide from me sometimes so -1 byte thanks to @HyperNeutrino)

How it Works

ÆDÆfQ€SS‘ḍ - define helper function: is input a BIU number?
ÆD             - divisors
  Æf           - list of prime factors
    Q€         - now distinct prime factors
      SS       - sum, then sum again ('' counts as 0)
        ‘      - add one (to account for '')
         ḍ     - does this divide the input?

1Ç#Ṫ - main link, input n
  #     - starting at 
1          - 1
        - get the first n integers which meet:
 Ç         - helper link
   Ṫ    - tail
|improve this answer|||||
  • \$\begingroup\$ -1 byte using ÆfQ€ instead of ÆFḢ€€ \$\endgroup\$ – HyperNeutrino Sep 27 '17 at 0:56
  • 2
    \$\begingroup\$ but they mysteriously hide from me sometime "Jelly is a game of atom hide and programmer seek" ~ i cri everytim \$\endgroup\$ – HyperNeutrino Sep 27 '17 at 1:14
  • \$\begingroup\$ I think you can save 1 byte with ÆDÆFSSḢ‘ḍ. \$\endgroup\$ – Arnauld Sep 27 '17 at 16:11

05AB1E, 9 bytes


Uses teh 05AB1E encoding. Try it online!

|improve this answer|||||

Mathematica, 85 bytes

|improve this answer|||||

Husk, 13 bytes


Try it online!


  Ṡ¦ö→ΣṁoupḊ    Predicate: returns 1 if BIU, else 0.
           Ḋ    List of divisors
       ṁ        Map and then concatenate
        oup     unique prime factors
      Σ         Sum
    ö→          Add one
  Ṡ¦            Is the argument divisible by this result
 f          N   Filter the natural numbers by that predicate
!               Index
|improve this answer|||||

Actually, 16 bytes


Try it online!


u⌠;÷♂y♂iΣu@%Y⌡╓   first n+1 numbers x starting with x=0 where
   ÷                divisors
    ♂y              prime factors of divisors
      ♂iΣu          sum of prime factors of divisors, plus 1
  ;       @%        x mod sum
            Y       is 0
               N  last number in list
|improve this answer|||||

Pyth, 22 bytes


Try it here!

This is my first ever Pyth solution, I began learning it thanks to the recommendations of some very kind users in chat :-)... Took me about an hour to solve.


e.f|qZ1!%Zhssm{Pd*M{yP  - Whole program. Q = input.

 .f                     - First Q integers with truthy results, using a variable Z.
     qZ1                - Is Z equal to 1?
   |                    - Logical OR.
                   {yP  - Prime factors, powerset, deduplicate.
                 *M     - Get the product of each. This chunck and ^ are for divisors.
              m}Pd      - Get the unique prime factors of each.
           ss           - Flatten and sum.
          h             - Increment (to handle that 1, bah)
       %Z               - Modulo the current integer by the sum above.
      !                 - Logical negation. 0 -> True, > 0 -> False.
e                       - Last element.
|improve this answer|||||

Haskell, 115 bytes

All of the list comprehensions here can probably be golfed down, but I'm not sure how. Golfing suggestions welcome! Try it online!

x!y=rem x y<1
b n=[a|a<-[1..],a!(1+sum[sum[z|z<-[2..m],m!z,and[not$z!x|x<-[2..z-1]]]|m<-[x|x<-[2..a],a!x]])]!!(n-1)


This answer is actually three functions mashed together.

divisors a = [x | x <- [2..a], rem a x == 0]
sumPrimeDivs m = sum [z | z <- [2..m], rem m z == 0, and [rem z x /= 0 | x <- [2..z-1]]]
biu n = [a | a <- [1..], rem a (1 + sum [sumPrimeDivs m | m <- divisors a]) == 0] !! (n-1)
|improve this answer|||||

Japt, 22 21 bytes

@¥(J±XvXâ ®k âÃxx Ä}a

Test it

I feel like the g function method should lead to a shorter solution, but I can't figure out how it works!


Implicit input of integer U.

@                  }a

Starting from 0, return the first number that returns true when passed through the following function, with X being the current number.

Xâ ®   Ã

Get the divisors (â) of X and pass each through a function.

k â

Get the factors (k) of the current element and remove the duplicates (â).


Reduce the array by addition after first doing the same to each sub-array.


Add 1 to the result.


Test if X is divisible by that number.

Increment J (initially -1) by the result of that test.


Check for equality with U.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy