Created
June 19, 2015 06:59
-
-
Save augusteo/c50ab10279fa0aace046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: 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