Skip to main content
cheers!
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 13 11 10 bytes

1-indexed solution:

#ȯṗdS¤+d←ḣ 

Try it online!

Ungolfed/Explanation

 ḣ -- in the range [1..N] # -- count the number where the following predicate is true ← -- decrement number, S d -- create lists of digits of number and decremented ¤+ -- concatenate, d -- interpret it as number and ȯṗ -- check if it's a prime number 

Thanks @Zgarb for -3 bytes!

Husk, 13 11 10 bytes

1-indexed solution:

#ȯṗdS¤+d←ḣ 

Try it online!

Ungolfed/Explanation

 ḣ -- in the range [1..N] # -- count the number where the following predicate is true ← -- decrement number, S d -- create lists of digits of number and decremented ¤+ -- concatenate, d -- interpret it as number and ȯṗ -- check if it's a prime number 

Husk, 13 11 10 bytes

1-indexed solution:

#ȯṗdS¤+d←ḣ 

Try it online!

Ungolfed/Explanation

 ḣ -- in the range [1..N] # -- count the number where the following predicate is true ← -- decrement number, S d -- create lists of digits of number and decremented ¤+ -- concatenate, d -- interpret it as number and ȯṗ -- check if it's a prime number 

Thanks @Zgarb for -3 bytes!

-1
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 13 1111 10 bytes

1-indexed solution:

£fȯṗdS¤+d←N#ȯṗdS¤+d←ḣ 

Try it online!Try it online!

Ungolfed/Explanation

£   -- Getin the index of input (0 if not exists) inrange [1..N] # f N -- ..allcount naturalthe numbersnumber filteredwhere by: the following predicate is true  ← --  decrement number,   S d --  create lists of digits of number and decremented   ¤+ --  concatenate,   d --  interpret it as number and   ȯṗ --  check if it's a prime number 

Husk, 13 11 bytes

1-indexed solution:

£fȯṗdS¤+d←N 

Try it online!

Ungolfed/Explanation

£  -- Get the index of input (0 if not exists) in .. f N -- ..all natural numbers filtered by:  ← --  decrement number,   S d --  create lists of digits of number and decremented   ¤+ --  concatenate,   d --  interpret it as number and   ȯṗ --  check if it's a prime number 

Husk, 13 11 10 bytes

1-indexed solution:

#ȯṗdS¤+d←ḣ 

Try it online!

Ungolfed/Explanation

  -- in the range [1..N] # -- count the number where the following predicate is true  ← -- decrement number, S d -- create lists of digits of number and decremented ¤+ -- concatenate, d -- interpret it as number and ȯṗ -- check if it's a prime number 
updated explanation
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 1313 11 bytes

1-indexed solution:

£fȯ£İpdS¤+d←N£fȯṗdS¤+d←N 

Try it online!Try it online!

Ungolfed/Explanation

£  -- Get the index of input (0 if not exists) in .. f  N  -- ..all natural numbers filtered by:    -- decrement number,   S d  -- create lists of digits of number and decremented number,   ¤+  -- concatenate,   d  -- interpret it as number and ȯ£İp ȯṗ -- check if it's a prime number 

Husk, 13 bytes

1-indexed solution:

£fȯ£İpdS¤+d←N 

Try it online!

Ungolfed/Explanation

£  -- Get the index of input (0 if not exists) in .. f  N  -- ..all natural numbers filtered by:    -- decrement number,   S d  -- create lists of digits of number and decremented number,   ¤+  -- concatenate,   d  -- interpret it as number and ȯ£İp  -- check if it's a prime number 

Husk, 13 11 bytes

1-indexed solution:

£fȯṗdS¤+d←N 

Try it online!

Ungolfed/Explanation

£ -- Get the index of input (0 if not exists) in .. f N -- ..all natural numbers filtered by: ← -- decrement number, S d -- create lists of digits of number and decremented ¤+ -- concatenate, d -- interpret it as number and ȯṗ -- check if it's a prime number 
added explanation
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading