# Tag Info

## New answers tagged number-theory

### Count how many numbers are divisible by perfect numbers in a given range

Vyxal, 11 bytes ṡƛ'∆K=;Ḋa;∑ Try it Online! 9 bytes with s flag 12 bytes accounting for space seperated inputs Explained ...
• 23.8k
1 vote

### Is this number evil?

Fig, $3\log_{256}(96)\approx$ 2.469 bytes OSb Try it online! Outputs using inverted truthiness (0 -> ...
• 3,835
1 vote

### Count the divisors of a number

Vyxal, 2 bytes KL Try it Online!

### Anti-divisors of a number

Ruby, 36 bytes ->n{(2..n).select{(n%_1*2-_1)**2<4}} Attempt This Online!
• 321

### Rotational Average

PowerShell Core, 45 bytes ($args-join'+'|iex)*("1"*($l=$args.Count))/$l Try it online!
• 1,878

### Rotational Average

Fig, $4\log_{256}(96)\approx$ 3.292 bytes OMmM Try it online! Port of Husk. Takes input as a list of digits. d (from digits) ...
• 3,835
1 vote

### Anti-divisors of a number

Go, 119 bytes func f(n int)(a[]int){for i:=2;i<n;i++{k:=n%i if i%2<1&&k==i/2||i%2>0&&(k==(i-1)/2||k==(i+1)/2){a=append(a,i)}} return} ...
• 3,593
1 vote

### Rotational Average

05AB1E, 3 bytes œÅA Port of @tybocopperkettle's Vyxal answer, so make sure to upvote him/her as well! Try it online or verify all test cases. Explanation: ...
• 109k
1 vote

### Anti-divisors of a number

Japt -f, 12 bytes ÊÉ©AìøUaN%UÑ Try it Without Flags, 13 bytes õ ÅkÈaU%XÑ ÊÉ Try it ...
• 36k

### Anti-divisors of a number

Fig, $14\log_{256}(96)\approx$ 11.524 bytes Fpax'>2A-h%x#x Try it online! ...
• 271

### Product of Divisors

Go, 65 64 bytes func p(n int)int{p,i:=1,1 for;i<=n;i++{if n%i<1{p*=i}} return p} Attempt This Online! Ungolfed -1 swapping ...
• 3,593
1 vote

### Product of Divisors

Prolog (SWI), 60 bytes A+N+S:-A>0,A-1+N+Q,(N mod A<1,S is Q*A;S=Q);S=1. N+S:-N+N+S. Try it online!
• 11.5k

### Product of Divisors

Vyxal, 2 bytes Explanation: K # Gets the divisors of a number Π # Product of array Try it Online!
• 199
1 vote

### Product of Divisors

Fig, $3\log_{256}(96)\approx$ 2.469 bytes *rk Try it online! Multiplication analog of the addition version.
• 3,835
1 vote

### Am I not good enough for you?

Fig, $3\log_{256}(96)\approx$ 2.469 bytes =Sk Try it online! ...
• 3,835
1 vote

### Is this number a prime?

K (ngn/k), 18 bytes 1=+/1>(!x)!'x:.1:0 Try it online!
• 11.5k

### Rotational Average

Vyxal, 3 bytes Ṗ⌊ṁ -2 bytes thanks to @lyxal Try it online! Explanation ...
• 1,284

### Advanced Binary Number System

Swift: - 187 bytes (standalone program) - 66 bytes (function f) (The question asks for a "program" so providing it as a program.) ...
• 121
1 vote

### Advanced Binary Number System

Japt -x, 10 bytes ôÂ¢@¶Xì ì2 Try it
• 36k

### Advanced Binary Number System

Ruby, 40 37 bytes f=->n{n<1?1:(0..n/2).last(5).sum(&f)} Try it online! Based on xnor's answer.
• 18.7k

### Advanced Binary Number System

05AB1E, 5 bytes bLCI¢ Try it online or verify all test cases. Explanation: ...
• 109k

### Advanced Binary Number System

Desmos, 75 bytes f(n)=∑_{k=0}^{10^N}0^{(n-∑_{j=0}^Nmod(floor(k/10^j),10)2^j)^2} N=log_2n Try It On Desmos! Try It On Desmos! - Prettified We can golf some bytes, ...
• 8,494

### Advanced Binary Number System

PARI/GP, 35 bytes f(n)=if(n<1,!n,sum(i=0,4,f(n\2-i))) Attempt This Online! A port of @xnor's Python answer. PARI/GP, 42 bytes ...
• 37.6k

### Advanced Binary Number System

Fig, $10\log_{256}(96)\approx$ 8.231 bytes IxeBefa_Ob Try it online! Port of caird's Jelly answer.
• 11.5k

### Advanced Binary Number System

JavaScript (ES6), 35 bytes Based on the OEIS formula found by dingledooper. f=n=>n<2?n>=0:f(n-2)+f(n/=2)-f(n-5) Try it online!
• 171k

### Advanced Binary Number System

C (gcc), 42 39 37 bytes f(n){n=n<1?!n:f(n-2)+f(n/=2)-f(n-5);} Try it online! Port of Arnauld's JavaScript answer based on dingledooper's Python answer!!! Saved ...
• 19k

### Advanced Binary Number System

Charcoal, 14 bytes ＮθＩ№Ｅ⊕⍘θ²⍘Ｉι²θ Try it online! Link is to verbose version of code. Explanation: Port of @caird's Jelly answer. ...
• 148k

### Advanced Binary Number System

Vyxal, 5 bytes ↵2vβO Try it Online! Times out after default time online for anything over 4, times out for all inputs over 5 after maximum time. Kind of similar to ...
• 23.8k

### Advanced Binary Number System

Python 2, 45 bytes Based on the conjectured formula presented in OEIS A309616. f=lambda n:n<2or-f(n/2-5)*(n>9)+f(n-2)+f(n/2) Try it online!
• 18.7k

### Advanced Binary Number System

Python, 53 bytes f=lambda n:sum(f(k)for k in range(n)if~9<2*k-n<1)or 1 Try it online! The if condition is golfed from <...
• 139k

### Advanced Binary Number System

Jelly, 6 bytes BḌRDḄċ Try it online! How it works For the input $x$, we generate the range $[1, n]$, where $n$ is the binary representation of $x$, treated ...
1 vote

### IMO Question Six with a difference

Ruby, 43 bytes ->n{(0..n).any?{|a|(n*n-2)%~(~a*~a+=n)==0}} Try it online!
• 18.7k
1 vote

### Split, flip and recombine integers

05AB1E, 14 bytes Ò2¢©o/<;§o®·>* Port of @emanresuA's Vyxal answer. Should have been 13 bytes, but there is a bug in 05AB1E's ...
• 109k

### Split, flip and recombine integers

Vyxal, 13 bytes 2Ǒ:£E/‹½E¥d›* Try it Online! ...
• 31.9k
1 vote

### Split, flip and recombine integers

HBL, 22 bytes 1(1.)(1.). ?(%.)(1(12(/.2))?)(()(?(/.2 +((). Try it here! Ungolfed/explanation Here's the same thing in HBL's companion language Thimble: ...
• 34.4k

### Count alternating permutations

Wolfram Language (Mathematica), 19 bytes 2Abs@PolyLog[-#,I]& Try it online! Equivalent to the PARI/GP answer by alephalpha, but I first came across this ...
• 1,023
1 vote

### IMO Question Six with a difference

J, 38 bytes 3 :'*/0<1|(_2+*:y)%1+(a+y)*a=.1+i.1+y' Uses @xnor's formula, but implements it directly on an array containing a from 1 to n+1. Try it here
• 3,482
1 vote

### IMO Question Six with a difference

Charcoal, 21 bytes Ｎθ⊙…·¹⊕θ¬﹪⁻×θθ²⊕×ι⁺ιθ Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - ...
• 148k

### IMO Question Six with a difference

R, 35 bytes \(n,a=1:n)all(n^2%%(a*(a+n)+1)-2)&n Attempt This Online! Outputs reversed TRUE/...
• 12.4k

### IMO Question Six with a difference

05AB1E, 13 11 bytes nÍILDI+*>Öà -2 bytes porting @xnor's formula as well Outputs 1/0 as ...
• 109k

### IMO Question Six with a difference

PARI/GP, 33 bytes n->n*prod(a=1,n,n^2%(1+a*a+=n)-2) Attempt This Online! A port of @pajonk's R port of @xnor's Python answer. Returns falsy when there is a ...
• 37.6k

### IMO Question Six with a difference

Pyth, 18 bytes lfsIc-*QQ2h*T+QTSh Test suite A naïve implementation of the algorithm layed out in @xnor's answer. I'll see if I can get a better score later.
• 4,191

### IMO Question Six with a difference

C (gcc), 50 bytes a;f(n){for(a=0;a++<=n&&(n*n-2)%~(a*(a+n)););a-=n;} Try it online! Port of xnor's Python answer. Returns $2$ for invalid and an ...
• 19k

### IMO Question Six with a difference

Python, 49 bytes f=lambda n,a=1:a>n+1or(n*n-2)%~(a*(a+n))*f(n,a+1) Try it online! Outputs Truthy/Falsey reversed. Checks whether $$\frac{n^2-2}{a(a+n)+1}$$ is ...
• 139k

### IMO Question Six with a difference

JavaScript (ES6), 43 bytes -4 bytes with the formula used in @xnor's answer Returns either 0 (falsy) or a positive integer (truthy). ...
• 171k

### Anti-divisors of a number

Brachylog, 16 bytes >.&;.%×₂;.-ȧ<2≤≜ A predicate that acts as a generator. Try it online! Explanation Brachylog's clunky arithmetic builtins make it less ...
• 34.4k

### Anti-divisors of a number

Pip -p, 15 bytes a%_AD_/2<1FI2,a Try It Online! Explanation ...
• 34.4k

### The "Fly straight, dammit" sequence

PowerShell Core, 111 bytes for($i=$r=1;$i-lt"$args"){for($a,$b=++$i,$r;$b){if($a-gt$b){$b,$a=$a,$b}$b%=$a}$r=(($r/$a),($r+$i+1))[!--$a]}$r Try it online!...
• 1,878
1 vote

### The "Fly straight, dammit" sequence

Raku, 46 bytes 1,1,{$_/($!=(++$+1)gcd$_)+(++$+2)*($!==1)}...* Try it online! This is an expression for the infinite sequence.
• 6,066