// Preferred filename: main.swift -- swiftc only permits top-level code in main.swift. /* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Isaac Gouy converted to Swift 3 by Sergo Beruashvili */ import Glibc //import Darwin import Foundation func approximate(_ n: Int) -> Double { var u = Array(repeating: 1.0, count: n) var v = Array(repeating: 0.0, count: n) for _ in 1...10 { multiplyAtAv(n,u,&v) multiplyAtAv(n,v,&u) } var vBv = 0.0, vv = 0.0 for i in 0.. Double { let ij = i+j return 1.0 / Double( ij*(ij+1)/2 + i+1 ) } func multiplyAv(_ n: Int, _ v: [Double], _ av: inout [Double]) { for i in 0..