We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

1

Keg, 43 36 6 bytes (SBCS) :;¡²$% Try it online! -30 bytes thanks to @JoKing No TIO as it needs to be updated due to a bug found with the ² operator. Transpiles to: from KegLib import * from Stackd import Stack stack = Stack() printed = False duplicate(stack) decrement(stack) factorial(stack) square(stack) swap(stack) maths(stack, '%') if not printed: ...


1

Wren, 64 51 42 bytes Fn.new{|x|(2...x).map{|n|x%n}.all{|n|n>0}} Explanation Fn.new{ // New anonymous function |x| // With the parameter x (2...x) // Generate the range from 2 to x-1 .map{|n|x%n} // Map every item in ...


1

Java, 169 Bytes isProbablePrime is only valid for 32 bit integers, but it is correct for every 32 bit integer, so this is a valid solution. (int n)->{int x=-1;for(int i=0;i<n;){x++;if(BigInteger.valueOf(x).isProbablePrime(15))i++;}String r="";while(x>0){x--;int m=x%26;r=(char)(m+97)+r;x=(x-m)/26;}return r;};


0

Pyth, 27 bytes VQ.VhZIP_b=ZbB;p*\a/Z26@GtZ Explaination: # Implicit Q = eval(input()) # Implicit Z = 0 VQ # for N in range(Q) .VhZ # for b in infinite_range(Z+1) IP_b # if is_prime(b) =Zb # ...


2

Java (JDK), 170 163 158 157 155 bytes String p(int n){int c=0,i,v=1;String s="";while(c<n){v++;for(i=2;i<=v;i++)if(v%i<1)break;if(i==v)c++;}while(v>0){s=(char)(~-v%26+97)+s;v=~-v/26;}return s;} Try it online! Thanks to @Delta for saving me 14 bytes in total


0

Add++, 36 bytes L,5*2^RßÞPABDBJVB]dG€Ωezߣ*BZB]A1_$: Try it online! Fairly inefficient. Iterates over each integer \$i\$ such that \$i \le 25x^2\$ and filters out composites and primes that don't contain \$n\$. Finally, we take the \$n\$th value of the remaining integers.


1

05AB1E, 18 bytes <Ø[₂‰˜0KZ27‹#}<Asè Isn't there a convenient builtin to do this shorter?.. I have the feeling I should be able to use one of the base-conversion builtins here, but it isn't really working out.. Can without a doubt be golfed substantially, though.. Try it online or verify some more test cases. Explanation: < # ...


1

APL(NARS), 99 chars, 198 bytes r←p w;i;k r←0⋄→0×⍳w<2⋄i←2⋄k←√w⋄→3 →0×⍳0=i∣w⋄i+←1 →2×⍳i≤k r←1 f←{v←√k←+/2*⍨⍺⍵⋄0=⍺×⍵:(p v)∧3=4∣v⋄p k} test: 0 f 13 0 0 f 9 0 2 f 3 1 3 f 4 0 0 f 7 1 0 f 9 0 4600 f 5603 1


0

Icon, 135 bytes procedure f(n) k:=seq()&s:=0&0=k%(i:=2to k)&s+:=1&i=k&s=1&p:=k-1&n-:=1&n=0 t:="";until t[1:1]:=char(97+p%26)&p:=p/26-1&p<0;return t end Try it online!


1

APL (Dyalog Unicode), 36 47 48 49 47 43 28 bytes Takes an array of two integers a b and returns the Boolean value of the statement a+bi is a Gaussian integer. Edit: +11 bytes because I misunderstood the definition of a Gaussian prime. +1 byte from correcting the answer again. +1 byte from a third bug fix. -2 bytes due to using a train instead of a dfn. -4 ...


4

Wolfram Language (Mathematica), 53 bytes Flatten[Tuples[Alphabet[],#]&/@Range@4,1][[Prime@#]]& Try it online!


3

Ruby -rprime, 48 47 46 43 bytes -5 bytes from GB. ->n{(?A..?Z*n).take(Prime.take(n)[-1])[-1]} Try it online!


8

Python 3,262 236 209 196 179 114 93 92 97 bytes def f(n): m=k=1;s='' while n:m*=k*k;k+=1;n-=m%k while k:s=chr(~-k%26+97)+s;k=~-k//26 return s Try it online! Fixed a bug mentioned by @benrg about getting a wrong output for the input 123. Thanks to: - @AdmBorkBork for help me getting started and save a few bytes - @Sriotchilism O'Zaic for saving me 6 ...


4

JavaScript (Node.js), 83 bytes f=(n,k=0)=>n?f(n-(g=d=>~k%d--?g(d):!d)(++k),k):k<0?'':f(n,k/26-1)+Buffer([k%26+65]) Try it online! Commented f = ( // f is a recursive function taking: n, // n = input k = 0 // k = counter ) => // n ? // if n is not equal to 0: ...


2

PHP, 69 bytes for($n=1,$a=a;$argn||!print$a;$m||--$argn,$a++)for($m=$n++;$n%$m--;); Try it online!


4

Jelly, 8 bytes ÆNḃ26ịØa A monadic Link which accepts a non-negative integer that yields a list of characters. Try it online! How? ÆNḃ26ịØa - Link: integer, n ÆN - nth prime 26 - literal 26 ḃ - bijective base Øa - literal list of characters = ['a', 'b', ..., 'z'] ị - index into


0

PHP, 135 bytes for(;++$n<1e4;$p||print"$n ")for($p=$i=0;$i<$l=strlen($n);$i++)for($j=1;$j++<$l-$i;$p|=$k)for($k=($m=substr($n,$i,$j))-1;$k&&$m%$k--;); Try it online! for(; // level 1 loop on ++$n<1e4; // all numbers from 1 to 10,000, $n is current number $p||print"$n\n" // at ...


Top 50 recent answers are included