Skip to main content
added 15 characters in body
Source Link
138 Aspen
  • 7.3k
  • 1
  • 5
  • 18

Scala, 228 226226 225 bytes

Saved 23 bytes thanks to the comment of @ceilingcat


Golfed version. Try it online!Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*2*i "*i)+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 

Scala, 228 226 bytes

Saved 2 bytes thanks to the comment of @ceilingcat


Golfed version. Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*2*i)+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 

Scala, 228 226 225 bytes

Saved 3 bytes thanks to the comment of @ceilingcat


Golfed version. Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>("  "*i)+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 
added 9 characters in body
Source Link
138 Aspen
  • 7.3k
  • 1
  • 5
  • 18

Scala, 228228 226 bytes

Saved 2 bytes thanks to the comment of @ceilingcat


Golfed version. Try it online!Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*(2*i)"*2*i)+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 

Scala, 228 bytes

Golfed version. Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*(2*i))+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 

Scala, 228 226 bytes

Saved 2 bytes thanks to the comment of @ceilingcat


Golfed version. Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*2*i)+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) } 
Source Link
138 Aspen
  • 7.3k
  • 1
  • 5
  • 18

Scala, 228 bytes

Golfed version. Try it online!

object Main extends App{def f(n:Int)={def g(a:Int,b:Int,n:Int):List[(Int,Int,Int)]=n match{case 0=>Nil case _=>(a,b,a+b)::g(b,a+b,n-1)};g(1,1,n)};f(20).zipWithIndex.map{case((a,b,c),i)=>(" "*(2*i))+s"$a+$b=$c"}.foreach(println)} 

Ungolfed version. Try it online!

object Main extends App { def formatList(list: List[(Int, Int, Int)]): List[String] = { list.zipWithIndex.map { case ((a, b, c), i) => (" " * (2 * i)) + s"$a + $b = $c" } } def fibonacciSeq(n: Int): List[(Int, Int, Int)] = { def fibHelper(a: Int, b: Int, n: Int): List[(Int, Int, Int)] = n match { case 0 => Nil case _ => (a, b, a + b) :: fibHelper(b, a + b, n - 1) } fibHelper(1, 1, n) } val formatted = formatList(fibonacciSeq(20)) formatted.foreach(println) }