Skip to main content
added 11 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 76 7373 69 bytes

ta#b=mod x=x<2||odda x&&tb<1&&t(div a b) t x=x<2||(x-1)2)||mod(x+1)3<1&&t(div#2||(x+1)3)#3 (filter t[1..]!!) 

Uses a 0-based index. Usage example: (filter t[1..]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

Haskell, 76 73 bytes

t x=x<2||odd x&&t(div(x-1)2)||mod(x+1)3<1&&t(div(x+1)3) (filter t[1..]!!) 

Uses a 0-based index. Usage example: (filter t[1..]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

Haskell, 76 73 69 bytes

a#b=mod a b<1&&t(div a b) t x=x<2||(x-1)#2||(x+1)#3 (filter t[1..]!!) 

Uses a 0-based index. Usage example: (filter t[1..]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

added 4 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 7676 73 bytes

t x=x<2||odd x&&t(div(x-1)2)||mod(x+1)3<1&&t(div(x+1)3) ([x|x<-[1filter t[1..],t x]!!) 

Uses a 0-based index. Usage example: ([x|x<-[1filter t[1..],t x]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most (all so far?) other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

Haskell, 76 bytes

t x=x<2||odd x&&t(div(x-1)2)||mod(x+1)3<1&&t(div(x+1)3) ([x|x<-[1..],t x]!!) 

Uses a 0-based index. Usage example: ([x|x<-[1..],t x]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most (all so far?) other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

Haskell, 76 73 bytes

t x=x<2||odd x&&t(div(x-1)2)||mod(x+1)3<1&&t(div(x+1)3) (filter t[1..]!!) 

Uses a 0-based index. Usage example: (filter t[1..]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.

Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 76 bytes

t x=x<2||odd x&&t(div(x-1)2)||mod(x+1)3<1&&t(div(x+1)3) ([x|x<-[1..],t x]!!) 

Uses a 0-based index. Usage example: ([x|x<-[1..],t x]!!) 54 -> 255.

Instead of building the list by repeatedly inserting 2x+1 and 3x-1 as seen in most (all so far?) other answers, I go through all integers and check if they can reduced to 1 by repeatedly applying (x-1) / 2 or (x+1) / 3 if divisible.