# Tag Info

15

Jelly, 6 bytes R×:<?/ A monadic Link accepting a positive integer, $n$, which yields a positive integer, $a(n)$. Try it online! Or see the test-suite. How? R×:<?/ - Link: R - range -> [1..n] / - reduce by (i.e. evaluate f(f(...f(f(f(1,2),3),4),...),n) with this f(a,b): ? - if... < - ...condition: (a) less than (b)? × ...

14

Haskell, 42 bytes f n=sum[0^mod n q|a<-[3..n],q<-[a,3*a..n]] Try it online! 51 bytes f n=sum[1|a<-[3..n],b<-[1,3..n],c<-[1..n],a*b*c==n] Try it online! The output is the number of ways to factor $n=abc$ into three positive factors, where $a \geq 3$, $b$ is odd, and $c$ is unconstrained.

14

Scratch 3.0, 29 27 blocks/234 167 bytes As SB Syntax: define f(n) if<(n)=(1)>then add(1)to[v v else f((n)-(1 set[d v]to(item(length of[v v])of[v v if<(n)>(d)>then add((n)*(d))to[v v else add([floor v] of ((n)/(d)))to[v v] end end when gf clicked delete all of [v v ask()and wait f(answer) Try it on scratch I'm a little unsure of some input/...

13

Shakespeare Programming Language, 221 bytes ,.Ajax,.Puck,. Act I:.Scene I:.[Enter Ajax and Puck] Ajax:You cat. Scene V:. Puck:You is the sum ofYou a cat. Ajax:Open heart.Is I nicer you?If notYou is the quotient betweenyou I. If soYou is the product ofyou I.Let usScene V. Try it online! Outputs the infinite list. Note however that there is no separator ...

11

Python 2, 47 43 39 bytes Saved 4 bytes thanks to xnor!!! Saved 4 bytes thanks to Neil!!! r=i=1 while 1:r=r/i or r*i;print r;i+=1 Try it online! Prints $\{a(n)\mid n \in \mathbb{N}\}$ as an infinite sequence.

10

R, 43 39 bytes -4 bytes thanks to Giuseppe. for(i in 1:scan())T=T%/%i^(2*(i<T)-1);T Try it online! Outputs the $n$th term, 1-indexed. Initializing the sequence with $a(0)=1$ also works, as the formula then gives $a(1)=1$ as desired. The variable T is coerced to the integer 1, and we apply repeatedly a more compact version of the formula: a(n)=\...

10

J, 14 bytes (%+./)&.(_&q:) Try it online! (%+./)&.(_&q:) &.(_&q:) number to prime exponents (%+./) divide them by their GCD &.(_&q:) prime exponents to number

8

05AB1E, 17 16 14 12 11 bytes ∞ʒÒDS{āQиg< Outputs the infinite sequence. -2 bytes thanks to @CommandMaster, which also opened up the opportunity to golf 2 more bytes -1 byte thanks to @ovs. Try it online. Explanation: ∞ # Push an infinite list of positive integers: [1,2,3,...] ʒ # Filter this list by: Ò # Get a list of its prime ...

8

Brachylog, 9 bytes -3 thanks to Unrelated String! This defines a predicate that unifies with all-inclusive-semi-primes. In Prolog this is equivalent to a generator, that will return all all-inclusive-semi-primes one by one. ḋĊcẹo~⟦₁& Try it online! ḋĊcẹo~⟦₁& ḋ prime factors Ċ are a pair (list of length 2) cẹ and the elements ...

8

05AB1E, 17 16 10 bytes 3÷ÝsÑÃÑÉOO Try it online! Edit: Saved 5 bytes thanks to @ovs. Explanation: 3÷L Get a list from 0 to n//3. sÑÃ Keep only factors of n. ÑÉO Number of odd divisors of each factor. O Output the sum.

8

APL (Dyalog Unicode), 18 bytes (SBCS) {⍺>⍵:⍺×⍵⋄⌊⍵÷⍺}/⌽ö⍳ Try it online! A barely-golfed but safe function that outputs the nth element of the sequence. APL (Dyalog Unicode), 15 14 bytes (SBCS) Saved 1 byte thanks to @Adám (⌊⊢×⊣*∘×-)/⌽ö⍳ Try it online! Outputs the nth element of the sequence. I just realized that this won't work if $n = a(n-1)$ ...

8

Haskell, 40 bytes a#n|n>a=a*n|1>0=adivn a=scanl1(#)[1..] Try it online! Outputs infinite sequence. Infix operator # computes next term, we use it to fold all positive integers [1..] but using scanl1 instead which gives us all steps.

8

Jelly, 10 bytes ÆEgƒ0:@ƊÆẸ Try it online! ÆE:g/$ÆẸ errors given 1. ÆE Take the exponents of the input's prime factorization. :@Ɗ Divide each exponent by gƒ0 the exponents' GCD (or 0 in the case that there are none). ÆẸ Let the result be the exponents of the output's prime factorization. 8 Brachylog, 6 bytes 1|~^hℕ Try it online! 1|~^hℕ with the implicit input n 1 input and output is 1 | or ~^ find two numbers [r, i] so that r^i = n h return r ℕ to limit the search space: r must be positive Search tries lowest i first, so we get the maximum r for free. 7 Python 2, 734 bytes import fractions as F,itertools as I r=range s=set P=lambda G,p=:[x for a,b in G if(p[-1]==a)*(1-(b in p))for x in(P(G,p+[b])if b-1else[p+[b]])] def R(G): G+=tuple((b,a)for a,b in G);B=s(b for a,b in G);n=1+max(B) if s(G)-s(x for p in P(G)for e in zip(p,p[1:])for x in[e,e[::-1]])or len(B)-n:return 0 M=[*(n+1)for _ in B];M,... 7 Perl 5 -Minteger -061, 36, 27 bytes -9 bytes thanks to @Abigail and @Sisyphus. outputs an infinite sequence say$/while$/=$//++$i||$/*$i Try it online! 7 Python 3.8+, 45 39 bytes -2 thanks to xnor (while print(...)!=0: → while[print(...)]:) -4 thanks to Neil ([a*n,a//n][a>n] → a//n or a*n) a=n=1 while[print(a:=a//n or a*n)]:n+=1 A full program which prints $a(n)$ for all natural numbers. Try it online! As a recursive function, 49: f=lambda v,n=1,a=1:a*(v<n)or f(v,n+1,a//n or a*n) 7 R, 41 bytes for(m in 1:scan())T=if(m>T,T*m,T%/%m);T Try it online! Forced myself not to look at Robin Ryder's R answer before having a go at this. Happily we came up with different approaches to each other, although both seem (so far) to be exactly the same length in bytes sadly for me his one is now 2 bytes shorter... 7 C (gcc), 35 bytes Takes a 1-based starting index and returns the nth sequence value. f(i,j){i=i?i>(j=f(i-1))?j*i:j/i:1;} Try it online! 7 Forth (gforth), 82 bytes : f 2dup 2dup > if * else swap / then dup . swap drop swap 1+ swap recurse ; 1 1 f Try it online! Outputs an infinite sequence, separated by spaces. 7 05AB1E, 8 11 8 bytes -3 thanks to @ovs! L¦BíCXkÌ Try it online! I am trying to somehow implement a log function to check whether a number matches the regex 10*, but that is too mathematical for me... Wait, how? L # Push all numbers natural numbers up to input [1, 2, 3 ... I] ¦ # What is that 1 doing there? Remove it! ... 7 Python 3, 55 $\cdots$ 59 57 bytes Added 7 bytes to fix an error kindly pointed by user. Saved 3 bytes thanks to user!!! lambda n:{r**i:r for i in range(n)for r in range(n+1)}[n] Try it online! 7 Husk, 8 bytes VȯεΣB¹ḣ Try it online! V # index of first truthy element of ȯ # applying 3 functions to ḣ # 1...input B¹ # convert input to this base Σ # sum of digits ε # is at most 1 6 05AB1E, 13 bytes Outputs all all-inclusive semi-primes, not quite in ascending order. 7°ÅpâʒS{āQ}PÙ Try it online! Commented: The S{āQ is borrowed from Kevin's answer. 7° # push 10^7 Åp # push the first 10^7 primes # the first 5694505 would be enough but costs more bytes â # take the cartesian product ... 6 JavaScript (Node.js), 38 35 bytes Saved 3 bytes thanks to @Neil Returns the $n$-th term, 1-indexed. f=(n,k=i=1n)=>i++<n?f(n,k/i||k*i):k Try it online! 6 Factor, 45 bytes [ [1,b] 1 [ 2dup < [ * ] [ /i ] if ] reduce ] Try it online! Straightforward reduction. Takes 1-based index and returns the n-th term. [ ! anonymous lambda [1,b] 1 [ ... ] reduce ! reduce {1..n} by the following, starting with 1: 2dup < ! ( an n -- an n an<n) [ * ] [ /i ] if ... 5 Husk, 21 19 18 16 14 bytes (or 15 bytes for versions that just output the n-th, or first n all-inclusive semi-primes, and so will always terminate instead of running indefinitely) Edit: -2 bytes thanks to Razetime's suggestion to just use p twice instead of my complicated approach of spending 3 bytes just to save one character... ...then another -1 byte, and ... 5 Stax, 22 21 17 16 bytes âH«q☻╧Ñ♦├x╓║Nm"° Run and debug it -1 byte using a generating block. -4 bytes using a filter. -1 byte from wastl. Outputs infinite list, separated by newlines. Explanation (Uncompressed) VIf|fY%2=y$eEc%R|}* VIf filter natural numbers, printing truthy values take current ...

5

J, 29 bytes [:+/@,[=[+/\\.@(*1+i.)~"+3+i. Try it online! [:+/@,[=[+/\\.@(*1+i.)~"+3+i. i. 0…N-1 3+ 3…N+2 "+ for each y in 3…N+2: [ (*1+i.)~ y * 0…N, thus f.e. 5 10 15 20 … for p_5 \\.@ take every possible sublist ...

5

Husk, 11 bytes Fμ?*÷<¹³)ḣ Try it online! F # Fold a function over ḣ # sequence from 1..input; μ?*÷<¹³) # function with 2 arguments: ? # if <¹³ # arg 2 is smaller than arg 1 * # arg 1 times arg 2 `÷ # else arg 1 integer divided by arg 2

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