object Main extends App{ val sc = new java.util.Scanner(System.in) val n = sc.nextInt def calc(n1: BigDecimal, n2: BigDecimal): Stream[BigDecimal] = { n1 #:: calc(n2, (19/4.0 * n2) - (12 / 4.0 * n1) ) } val res = calc(4, 3).take(n+1).last println(res) }