19

Jelly, 15 11 10 bytes Hð+,_ðH²_½ Try it online! The following binary code works with this version of the Jelly interpreter. 0000000: 48 98 2b 2c 5f 98 48 8a 5f 90 H.+,_.H._. Idea This is based on the fact that Code Hð+,_ðH²_½ Left input: s -- Right input: p ð ð This is a link fork. We define three links, call the left and right ...


19

05AB1E, 2 bytes ÑO Try it online! How? Ñ Divisors O Sum


16

PowerShell v3+, 450 bytes param($n)function f{param($a)for($i=2;$a-gt1){if(!($a%$i)){$i;$a/=$i}else{$i++}}} $y=($x=@((f $n)-split'(.)'-ne''|sort))|?{$_-eq(f $_)} $a,$b=$x $a=,$a while($b){$z,$b=$b;$a=$a+($a+$y|%{$c="$_";0..$c.Length|%{-join($c[0..$_]+$z+$c[++$_..$c.Length])};"$z$c";"$c$z"})|select -u} $x=-join($x|sort -des) $l=@();$a|?{$_-eq(f $_)}|%{$j=$_;...


16

Brachylog, 4 bytes fk+? Try it online! The predicate succeeds for perfect inputs and fails for imperfect inputs, printing true. or false. if run as a complete program (except on the last test case which takes more than a minute on TIO). The input's f factors k without the last element + sum to ? the input.


15

Pyth, 1 byte P I like Pyth's chances in this challenge.


14

Python 2, 55 bytes f=lambda n,k=2:n/k*[0]and(f(n,k+1),[k]+f(n/k,k))[n%k<1] Try it online!


14

Husk, 35 31 30 29 26 25 24 22 20 19 15 bytes -7 bytes thanks to @Zgarb! Saved an extra 4 bytes, indirectly, thanks to Zgarb ḋhΣhgφṁȯ`Jḋ2⁰ṗp Try it online! Explaination φ -- Define a recursive function which calls itself ⁰ and is applied to an Integer ṁ p -- map then concatenate over its prime factors ṗ -- ...


14

Jelly, 15 bytes ¹ÆFṛÇṭ¥Ị?@/€$Ẓ? Try it online! A full program that takes the number and outputs the answer. This isn't a link because I am using "last link" to refer to itself, so it would break as a link on its own. I fix this for my test suite by making the last link a single atom that calls the next link. For whatever reason, "this link&...


13

Unicorn, 4650 2982 1874 1546 [ ✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨ 🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄 ( 🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈 🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄 🌈�...


12

SageMath, 31 Bytes N=input() print N,"=",factor(N) Test case: 83891573479027823458394579234582347590825792034579235923475902312344444 Outputs: 83891573479027823458394579234582347590825792034579235923475902312344444 = 2^2 * 3^2 * 89395597 * 98966790508447596609239 * 263396636003096040031295425789508274613


12

Proof that every repunit has a novel prime factor Using Zsigmondy's Theorem, the proof is simple. From Wikipedia: In number theory, Zsigmondy's theorem, named after Karl Zsigmondy, states that if a > b > 0 are coprime integers, then for any integer n ≥ 1, there is a prime number p (called a primitive prime divisor) that divides an − bn and does not ...


11

Python 2, 53 bytes f=lambda n,i=2:n/i*[f]and[f(n,i+1),[i]+f(n/i)][n%i<1] Tries each potential divisor i in turn. If i is a divisor, prepends it and restarts with n/i. Else, tries the next-highest divisor. Because divisors are checked in increasing order, only the prime ones are found. As a program, for 55 bytes: n=input();i=2 while~-n: if n%i:i+=1 ...


10

Julia, 95 93 bytes g(x)=reduce(vcat,map(p->map(sum,p),partitions([keys(factor(x))...]))) f(a,b)=g(a)∩g(b)!=[] The primary function is f and it calls a helper function g. Ungolfed: function g(x::Integer) # Find the sum of each combination of prime factors of the input return reduce(vcat, map(p -> map(sum, p), partitions([keys(factor(x))...]))...


10

Jelly, 12 bytes Æf*³<‘Ạ 1Ç#Ṫ Takes n and k (one-indexed) as command-line arguments. Try it online! How it works 1Ç#Ṫ Main link. Left argument: n. Right argument: k 1 Set the return value to 1. Ç# Execute the helper link above for r = 1, 2, 3, ... until k of them return a truthy value. Yield the list of all k matches. Ṫ ...


10

Python3, 49 47 bytes def f(x): l=x**.5//1 while x%l:l-=1 return l Explanation l=x**.5//1 → Assign l the largest integer less than equal to the square root of x while x%l:l-=1 → While l does not evenly divide x, decrement l. Edits Mention Python3, not Python2 Use ...//1 to save two bytes. (Decimals are okay! Thanks @Rod)


10

JavaScript (ES6),  45  44 bytes Takes input as (n)(p1), where \$n\$ is 0-indexed. n=>g=(p,d=2)=>n?~p%d?g(p,d+1):--n?g(p*d):d:p Try it online! Commented n => // n = 0-based index of the requested term g = ( // g is a recursive function taking: p, // p = current prime product d = 2 // d ...


10

Scala 3, 49 44 bytes a=>b=>(-b*b to b*b)map(p=>a-p->p)find(_*_==b) Try it onlne! Takes (a)(b) and returns an Option[(Int, Int)]. It's now a little more inefficient since it goes from \$-b^2\$ to \$b^2\$ instead of \$-|b|\$ to \$|b|\$, including values that \$p\$ and \$q\$ could never be, but it saves 4 bytes. a => b => (-b*b to b*b) ...


9

Husk, 11 10 bytes Saved one byte thanks to Zgarb! Ωεo?oṗ←¬Ep Returns 1 for unique, 0 otherwise Try it online! Or returning the first 50 Explanation: Ωε Until the result is small (either 1 or 0), we repeat the following p Get the prime factors o? If ... E they are all equal: ȯṗ← Get the index ...


9

R, 33 29 bytes !2*(n=scan())-(x=1:n)%*%!n%%x Try it online! Returns TRUE for perfect numbers and FALSE for imperfect ones.


9

Neim, 3 bytes 𝐕𝐬𝔼 Try it online! (I don't actually know how to run all of the test cases at once, since I started learning Neim about fifteen minutes ago, but I did check them individually.) Prints 0 for imperfect, 1 for perfect. 𝐕 Pop an int from the stack and push its proper divisors, implicitly reading the int from a line of input as ...


9

05AB1E, 6 bytes This produces and infinite output stream. λλP>fW Try it online! (link includes a slightly modified version, λ£λP>fW, which instead outputs the first \$n\$ terms) Explanation Very straightforward. Given \$p_1\$ and \$n\$, the program does the following: Starts with \$p_1\$ as an initial parameter for the infinite stream (which is ...


9

Haskell, 53 bytes f b=[x|x<-[b..],k<-[2..x-1],mod x k+gcd(b^3-b)x<2]!!0 Try it online!


9

JavaScript (ES7),  37 36 34  31 bytes Saved 3 bytes thanks to @tsh Expects (a)(b). a=>b=>[b=a/2+(a*a/4-b)**.5,a-b] Try it online!


9

Wolfram Language (Mathematica), 23 21 18 bytes Solve[x x+#2==x#]& Try it online!


8

Java - 124 String f(int t){int s=2,h=3,p=s,i;String o="";for(;p!=t&&s*s<t;p=p<t?p*h++:p/s++);if(p==t)for(i=s;i<h;o+++=i+" ");return o;} Starting at 2, this loops until the start number is > the square root of the target (or target is reached exactly). If the product is low, it multiplies by the high number and ...


8

Python - 104 97 95 92 try it n=input() s=i=2 c=1 while s<n: s*=i+c;c+=1 if s==n:print range(i,i+c) if s/n:i+=1;s,c=i,1 If n is, e.g., set to 120 beforehand, the program outputs the two solutions: [2, 3, 4, 5] [4, 5, 6]


8

JavaScript ES6, 45 39 37* bytes (q,p)=>[x=p/2+Math.sqrt(p*p/4-q),p-x] * Thanks to Dennis!


8

CJam, 26 23 bytes {_mfs$:XW%i){mfs$X=},^} Try it online Explanation Concatenating two numbers always gives a bigger result than multiplying them. So the largest number we possibly need to consider is the largest number we can form from the digits of the input's prime factorisation, which is just all digits sorted in descending order. For the given ...


8

Mathematica, 38 30 bytes Thanks @MartinEnder for 8 bytes! Join@@Table@@@FactorInteger@#&


8

Jelly,  22 20  19 bytes -1 thanks to Erik the Outgolfer (tail zeros from both sides, t, rather than from the right œr) ÆfÆC$ÐLŒṘO%3ḟ2Ḋt0ṖḄ A monadic link taking an integer greater than 2 and returning an integer greater than 0 (2 would return 0 as per the original spec too). Try it online! How? This almost exactly replicates the description ...


Only top voted, non community-wiki answers of a minimum length are eligible