{"id":1880,"date":"2018-04-20T22:28:47","date_gmt":"2018-04-20T13:28:47","guid":{"rendered":"https:\/\/www.beeete2.com\/blog\/?p=1880"},"modified":"2018-04-20T22:28:47","modified_gmt":"2018-04-20T13:28:47","slug":"a-tour-of-go%e3%81%aeexercise-loops-and-functions%e3%81%8c%e9%9b%a3%e3%81%97%e3%81%84%e3%83%bb%e3%83%bb%e3%83%bb","status":"publish","type":"post","link":"https:\/\/www.beeete2.com\/blog\/?p=1880","title":{"rendered":"A Tour of Go\u306eExercise: Loops and Functions\u304c\u96e3\u3057\u3044\u30fb\u30fb\u30fb"},"content":{"rendered":"<p>\u6628\u65e5\u304b\u3089A Tour Of Go\u3092\u306f\u3058\u3081\u307e\u3057\u305f\u3002<br \/>\n\u7686\u3055\u3093\u30aa\u30ea\u30b8\u30ca\u30eb\uff08\u82f1\u8a9e\u7248\uff09\u3092\u3084\u3063\u3066\u898b\u308b\u3088\u3046\u306b\u3068\u9032\u3081\u3066\u304f\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u307e\u305a\u306f\u65e5\u672c\u8a9e\u3092\u9032\u3081\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u3057\u3066\u65e9\u901fExercise: Loops and Functions\u3067\u3064\u307e\u3065\u304d\u307e\u3057\u305f\u3002<br \/>\n\u66f8\u3044\u3066\u3042\u308b\u3053\u3068\u304c\u5168\u304f\u308f\u304b\u3089\u305a\u98db\u3070\u305d\u3046\u304b\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u4f55\u5ea6\u3082\u8aad\u307f\u8fd4\u3057\u3066\u3088\u3046\u3084\u304f\u610f\u5473\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<br \/>\n\u30eb\u30fc\u30d7\u5185\u3067z -= (z<em>z &#8211; x) \/ (2<\/em>z)\u3092\u5b9f\u884c\u3057\u3066z\u3068\u524d\u56de\u5b9f\u884c\u6642\u306ez\u306e\u5dee\u304c\u4e00\u5b9a\u5024\u4ee5\u4e0b\u306b\u306a\u3063\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\u3068\u3044\u3046\u3053\u3068\u3060\u3068\u601d\u3044\u3068\u308a\u3042\u3048\u305a\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre><code class=\"language-go\">\npackage main\n\nimport (\n    \"fmt\"\n    \"math\"\n)\n\nfunc Sqrt(x float64) float64 {\n    z := 1.0\n    n := 0.0\n    for i := 0; i < 10; i++ {\n        z -= (z*z - x) \/ (2 * z)\n        if math.Abs(z-n) < 0.0000001 {\n            return z\n        }\n        n = z\n    }\n\n    return z\n}\n\nfunc main() {\n    x := 2.0\n    fmt.Println(Sqrt(x))\n    fmt.Println(math.Sqrt(x))\n}\n<\/code>\n<\/pre>\n<p>\u7d50\u679c<\/p>\n<pre><code class=\"language-go\">\n1.4142135623730951\n1.4142135623730951\n<\/code><\/pre>\n<p>\u7b54\u3048\u304c\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u5927\u304d\u304f\u5916\u3057\u3066\u3044\u306a\u3044\u3053\u3068\u3092\u304a\u7948\u308a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6628\u65e5\u304b\u3089A Tour Of Go\u3092\u306f\u3058\u3081\u307e\u3057\u305f\u3002 \u7686\u3055\u3093\u30aa\u30ea\u30b8\u30ca\u30eb\uff08\u82f1\u8a9e\u7248\uff09\u3092\u3084\u3063\u3066\u898b\u308b\u3088\u3046\u306b\u3068\u9032\u3081\u3066\u304f\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u307e\u305a\u306f\u65e5\u672c\u8a9e\u3092\u9032\u3081\u3066\u3044\u307e\u3059\u3002 \u305d\u3057\u3066\u65e9\u901fExercise: Loops and &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1877,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81],"tags":[],"views":3398,"_links":{"self":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1880"}],"collection":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1880"}],"version-history":[{"count":6,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1880\/revisions"}],"predecessor-version":[{"id":1886,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1880\/revisions\/1886"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/1877"}],"wp:attachment":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}