Skip to content

Instantly share code, notes, and snippets.

@augusteo
Created June 19, 2015 06:59
Show Gist options
  • Save augusteo/c50ab10279fa0aace046 to your computer and use it in GitHub Desktop.
Save augusteo/c50ab10279fa0aace046 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
func firstNNumbersOf(base: Double, powerOf: Double, firstN: Double) -> Double {
let x = powerOf * log10(base)
print("log 10 of \(base) is \(log10(base))")
print("x is \(x)")
let p = x - floor(x) + firstN - 1
print("p is \(p)")
return floor(pow(10, p))
}
firstNNumbersOf(2, powerOf: 123456789, firstN: 15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment