Created
May 17, 2016 02:54
-
-
Save andersonfraga/7e405a39cff2ef1bbd27d625a95d1e5c to your computer and use it in GitHub Desktop.
Brincando com go... But, tem será maneira mais 'go-style' de fazer isso?
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
package main | |
import "os" | |
import "fmt" | |
import "math" | |
import "strconv" | |
func main() { | |
number, _ := strconv.ParseFloat(os.Args[1:2][0], 64) | |
denom := float64(2) | |
_number := float64(0) | |
for number > 0 { | |
denom = math.Ceil(1/number) | |
_number = number - (1/denom) | |
fmt.Println("1 /", denom, "\n=", _number) | |
number = _number | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Talvez assim.. :)