New answers tagged

1 vote

Output a 1-2-3-5-7... sequence

Python 3 (sympy), 126 bytes from sympy import* s=[] g=x=0 while 1: x+=1;g=nextprime(g) if all(f%x or~-isprime(f//x)*(x-f)for f in s):print(g*x);s+=[g*x] Try it ...
CursorCoercer's user avatar
2 votes

Output a 1-2-3 sequence

x86-64 machine code, 24 bytes 31 C0 8D 70 07 FF C0 50 F7 E0 F7 F6 89 D1 E3 FA 58 E2 F2 FF CF 79 EE C3 Try it online! Following the standard calling convention for ...
m90's user avatar
  • 10.3k
0 votes

Output a 1-2-3 sequence

Ruby, 36 bytes 0.step{|x|x.to_s(7)=~/[25]0*/&&p(x)} Try it online! Using m90's method
G B's user avatar
  • 21.9k
1 vote

Output a 1-2-3-5-7... sequence

Wolfram Language (Mathematica), 74 bytes f@n_:=f/;!Or@@CompositeQ/@NumeratorDenominator[i/n]=Print@n f@i~Do~{i,∞} Try it online! Greedy algorithm. Outputs (certain ...
att's user avatar
  • 20.4k
1 vote

Output a 1-2-3 sequence

05AB1E, 7 bytes ∞ʒÒ<O3Ö Port of @Bubbler's Jelly answer, but with an infinite list instead. Try it online. Explanation: ...
Kevin Cruijssen's user avatar
1 vote

Output a 1-2-3 sequence

Haskell, 32 bytes [n|n<-[1..],mod(gcd(6^n)n^2)7<2] Try it online! An adaptation of m90's method. Extracts the 2^a * 3^b ...
xnor's user avatar
  • 145k
8 votes

Output a 1-2-3 sequence

JavaScript, 52 51 bytes for(n=0;h=x=>x%7||h(x/7);)~h(++n)%3||console.log(n) Try it online! -1 thanks to Mukundan314. The sequence contains the numbers that are ...
m90's user avatar
  • 10.3k
1 vote

Output a 1-2-3 sequence

C (GCC), 63 bytes i;main(j){for(;;~j%7%3||printf("%d ",i))for(j=++i;j%7<1;)j/=7;} Attempt This Online! Port of @m90's answer C (gcc), 82 74 bytes -8 ...
Mukundan314's user avatar
  • 10.5k
1 vote

Output a 1-2-3 sequence

Matlab, 69 66 bytes i=1;a=[];while 1;if all(a-i);disp(i);a=[a [2:4 9]*i];end;i=i+1;end Try it online! It basically is a translation of pxeger's answer. Matlab ...
Xenox's user avatar
  • 171
5 votes

Output a 1-2-3-5-7... sequence

05AB1E, 11 9 bytes ∞ʒÓ2ôÆƶO_ Try it online! Outputs the infinite sequence (well on TIO it will time out after about 18000). ...
Neil's user avatar
  • 170k
5 votes

Output a 1-2-3-5-7... sequence

JavaScript (V8), 82 bytes for(i=0,g=x=>x%k?k<i&&g(x,g[-i%k++||i]=z+=!g[k]):z^g(x/k);k=2;z=1)g(++i)||print(i) Try it online! att's method but on \$\...
l4m2's user avatar
  • 23.9k
5 votes

Output a 1-2-3 sequence

Vyxal, 6 bytes ǐ‹∑₃)ȯ Try it Online! A port of Bubbler's excellent Jelly answer. Go upvote that too. Explained ...
lyxal's user avatar
  • 33.3k
9 votes

Output a 1-2-3 sequence

Jelly, 8 bytes Æf’S3ḍµ# Try it online! A positive integer \$n = 2^a 3^b 5^c 7^d \cdots\$ belongs to a group identified by \$5^c 7^d \cdots\$ (i.e. the largest ...
Bubbler's user avatar
  • 76k
3 votes

Output a 1-2-3 sequence

Wolfram Language (Mathematica), 43 bytes f@n_:=f[2n|3n|4n|9n]=Print@n f@i~Do~{i,∞} Try it online! Outputs an infinite sequence. Same sequence as probably all the ...
att's user avatar
  • 20.4k
2 votes

Output a 1-2-3 sequence

JavaScript (V8), 53 bytes for(i=1;g=i=>i%3?i&-i:g(i/3*4);i++)g(i)%7-1||print(i) Try it online! Can port to C(70 bytes) JavaScript (V8), 57 bytes ...
l4m2's user avatar
  • 23.9k
2 votes

Output a 1-2-3 sequence

Vyxal 3, 11 bytes ÞṆΩ2Mn3M-3Ḋ Outputs A339746 as an infinite sequence. Try it Online! (times out) | Range instead of infinite list ...
math scat's user avatar
  • 9,228
4 votes

Output a 1-2-3 sequence

Charcoal, 36 bytes Nθ≔⁰ηW‹ⅉθ«≦⊕η¿¬﹪↨E23⌕X⁰⮌↨ηIκ⁰±¹¦³⟦Iη Try it online! Link is to verbose version of code. Explanation: ...
Neil's user avatar
  • 170k
7 votes

Output a 1-2-3 sequence

Python 2, 61 bytes i,=a={0} while 1: if{i}-a:print i;a|={i*2,i*3,i*4,i*9} i+=1 Attempt This Online! -4 thanks to Jonathan Allan and Mukundan314. This is A339746, ...
pxeger's user avatar
  • 23.7k
2 votes

Output a 1-2-3 sequence

Jelly, 9 bytes ọⱮ3IṪ3ḍµ# A full program that accepts a number, \$n\$, from stdin and prints a Jelly representation of a list of the first \$n\$ natural numbers for ...
Jonathan Allan's user avatar
0 votes

Mapping Passing Through Point

JavaScript (Node.js), 55 bytes f=(p,a,b,x,y,c,d)=>p>x?f(p,x,y,c,d):(y-b)/(x-a)*(p-a)+b Try it online! The linear map must be not shortest Two segments
l4m2's user avatar
  • 23.9k

Top 50 recent answers are included