Post History
Scala, 78 67 64 bytes Saved 3 bytes thanks to Razetime Stream.iterate(_)(x=>math.pow(x,x%2+.5).toInt).takeWhile(_>1):+1 Try it in Scastie! Stream.iterate(_) //Make an infinite list by r...
Answer
#3: Post edited
# Scala, <s>78</s> 67 bytes- ```scala
Stream.iterate(_)(x=>math.pow(x,x%2+1/2.0).toInt).takeWhile(_>1):+1- ```
[Try it in Scastie!](https://scastie.scala-lang.org/dQO2Rb8sRFiG5HT78jdryg)- ```
- Stream.iterate(_) //Make an infinite list by repeatedly applying
- (x=> //the following function to the input
- math.pow(x, //Raise x to the power of
- x%2 //x%2 (0 or 1)
+1/2.0 //plus .5 (.5 or 1.5)- ).toInt //Floor it
- ).takeWhile(_>1) //Take all elements until it hits 1
- :+1 //Append a 1
- ```
- # Scala, <s>78 67</s> 64 bytes
- Saved 3 bytes thanks to Razetime
- ```scala
- Stream.iterate(_)(x=>math.pow(x,x%2+.5).toInt).takeWhile(_>1):+1
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/Ihm2Gb3UQRWIoiv7fEW1rg)
- ```
- Stream.iterate(_) //Make an infinite list by repeatedly applying
- (x=> //the following function to the input
- math.pow(x, //Raise x to the power of
- x%2 //x%2 (0 or 1)
- +.5 //plus .5 (.5 or 1.5)
- ).toInt //Floor it
- ).takeWhile(_>1) //Take all elements until it hits 1
- :+1 //Append a 1
- ```
#2: Post edited
# Scala, 78 bytes- ```scala
Stream.iterate(_)(x=>math.sqrt(if(x%2<1)x else x*x*x).toInt).takeWhile(_>1):+1- ```
[Try it in Scastie!](https://scastie.scala-lang.org/UUEIWCugQSOUr2gTfFLo7w)- ```
- Stream.iterate(_) //Make an infinite list by repeatedly applying
- (x=> //the following function to the input
math.sqrt( //Take the square root ofif(x%2<1)x else x*x*x //x or x^3, depending on the parity- ).toInt //Floor it
- ).takeWhile(_>1) //Take all elements until it hits 1
- :+1 //Append a 1
- ```
- # Scala, <s>78</s> 67 bytes
- ```scala
- Stream.iterate(_)(x=>math.pow(x,x%2+1/2.0).toInt).takeWhile(_>1):+1
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/dQO2Rb8sRFiG5HT78jdryg)
- ```
- Stream.iterate(_) //Make an infinite list by repeatedly applying
- (x=> //the following function to the input
- math.pow(x, //Raise x to the power of
- x%2 //x%2 (0 or 1)
- +1/2.0 //plus .5 (.5 or 1.5)
- ).toInt //Floor it
- ).takeWhile(_>1) //Take all elements until it hits 1
- :+1 //Append a 1
- ```
#1: Initial revision
# Scala, 78 bytes ```scala Stream.iterate(_)(x=>math.sqrt(if(x%2<1)x else x*x*x).toInt).takeWhile(_>1):+1 ``` [Try it in Scastie!](https://scastie.scala-lang.org/UUEIWCugQSOUr2gTfFLo7w) ``` Stream.iterate(_) //Make an infinite list by repeatedly applying (x=> //the following function to the input math.sqrt( //Take the square root of if(x%2<1)x else x*x*x //x or x^3, depending on the parity ).toInt //Floor it ).takeWhile(_>1) //Take all elements until it hits 1 :+1 //Append a 1 ```