Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
3/14なので円周率を計算する
Search
Masayuki Mizuno
April 04, 2024
530
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
3/14なので円周率を計算する
Masayuki Mizuno
April 04, 2024
Transcript
28 slides
©2024 Wantedly, Inc. 3/14 ͳͷͰԁपΛܭࢉ͢Δ ͋Δ͍Rubyʹ͓͚Δҙਫ਼ܭࢉͱฒߦܭࢉΛࢼ͢ Omotesando.rb #96 Apr 4,
2024 - Masayuki Mizuno
©2024 Wantedly, Inc. ࠓ͢͜ͱ
©2024 Wantedly, Inc. ࠓ͢͜ͱ 3VCZʹΑΔԁपܭࢉϓϩάϥϜͷ࣮ ҙਫ਼ܭࢉϥΠϒϥϦͷൺֱ w *OUFHFS w #JH%FDJNBM
w (.1 ฒྻԽʹΑΔߴԽͷࢼΈ w 3BDUPS w ./εϨου
©2024 Wantedly, Inc. 3VCZʹΑΔԁपܭࢉϓϩάϥϜͷ࣮
©2024 Wantedly, Inc. ࣮ͷࠎࢠ͜Ε͚ͩ ࣮ͷৄࡉʹ͍ͭͯ͜Ε͔Βղઆ͠·͢ 3VCZʹΑΔԁपܭࢉϓϩάϥϜͷ࣮ https://gist.github.com/fetburner/4bb017fd6c4197894f97aac755749c45
©2024 Wantedly, Inc. $IVEOPWTLZͷެࣜ w ऩଋ͕ͱ͍ͯ w ԁपஹܻͷܭࢉʹΘΕͨ w #JOBSZTQMJUUJOH๏Ͱ࣌ؒܭࢉྔͱฒྻੑΛվળՄೳ
༻ͨ͠ެࣜ 1 π = 12 ∞ ∑ n=0 (−1)n(6n)! (3n)!(n!)3 545140134n + 13591409 6403203n+ 3 2
©2024 Wantedly, Inc. #JOBSZTQMJUUJOH๏ ڃܭࢉͷܭࢉྔͱฒྻੑΛվળ͢ΔςΫχοΫ w ԁप/ܻͷ࣌ؒܭࢉྔ͕ʹམͪΔ w ڞ௨͢ΔͷࢉΛݮͭͭ͠ɺ֤߲ͷܭࢉฒྻʹߦ͑Δ ׂ౷࣏๏ʹجͮ͘
w ࢉͷίετେ͖͍ํͷܻʹґଘ w ࣅͨΑ͏ͳܻಉ࢜Ͱܭࢉ͕ਐΉΑ͏εέδϡʔϧ O(N(log N)3)
©2024 Wantedly, Inc. ڞ௨͢ΔΛׅΓग़͢ ϗʔφʔ๏ͷཁྖ #JOBSZTQMJUUJOH๏ͷ࣮ྫ $IVEOPWTLZͷެࣜͷద༻ 6403203 12π
= ∞ ∑ k=0 (−1)n(6n)! (3n)!(n!)3 545140134n + 13591409 6403203n = 13591409 1 + (−1)6!(13591409 + 545140134) 3!(1!)36403203 + (−1)212!(13591409 + 2 ⋅ 545140134) 6!(2!)36403206 ⋯ = 13591409 + 1 ⋅ 1 ⋅ 5 1310939058860032000 ( (−1)(13591409 + 545140134) + 3 ⋅ 7 ⋅ 11 2310939058860032000 ((−1)2(13591409 + 2 ⋅ 545140134) + 5 ⋅ 13 ⋅ 17 3310939058860032000 (⋯)))
©2024 Wantedly, Inc. ༗ཧͰܭࢉΛਐΊΔͱߦྻੵʹؼணͰ͖Δ #JOBSZTQMJUUJOH๏ͷ࣮ྫ $IVEOPWTLZͷެࣜͷద༻ M N =
1 ⋅ 1 ⋅ 5 1310939058860032000 ((−1)(13591409 + 545140134) + 3 ⋅ 7 ⋅ 11 2310939058860032000 ((−1)2(13591409 + 2 ⋅ 545140134) + 5 ⋅ 13 ⋅ 17 3310939058860032000 (⋯))) π = 4270934400N 10005(M + 13591409N) ( M N) = ( 1 ⋅ 1 ⋅ 5 1 ⋅ 1 ⋅ 5 ⋅ (−1)(13591409 + 545140134) 0 1310939058860032000 ) ( 3 ⋅ 7 ⋅ 11 3 ⋅ 7 ⋅ 11 ⋅ (−1)2(13591409 + 2 ⋅ 545140134) 0 2310939058860032000 )⋯( 0 1) আࢉߴίετͳͷͰ࠷ޙʹ·ͱΊͯߦ͏
©2024 Wantedly, Inc. ಉܻ͡ಉ࢜Ͱܭࢉ͕ਐΉΑ͏ʹߦྻੵΛܭࢉ #JOBSZTQMJUUJOH๏ͷ࣮ྫ $IVEOPWTLZͷެࣜͷద༻ ҙਫ਼ࢉͷίετେ͖͍ํͷܻʹґଘ
©2024 Wantedly, Inc. ҙਫ਼ܭࢉϥΠϒϥϦͷൺֱ
©2024 Wantedly, Inc. 3VCZͷҙਫ਼ܭࢉϥΠϒϥϦҰཡ ΈࠐΈϥΠϒϥϦ CJHEFDJNBM HNQ *OUFHFS
(.1; ුಈখ #JH%FDJNBM (.1'
©2024 Wantedly, Inc. ΈࠐΈϥΠϒϥϦ *OUFHFSҙਫ਼ͷԋࢉ͕ߦ͑Δ w 3VCZҎલݻఆਫ਼ͷ'JYOVNͱҙਫ਼ͷ#JHOVNʹ͔Ε͍ͯͨ w 3VCZ͔Β*OUFHFSʹ౷Ұ͞Εͨ 'MPBUݻఆਫ਼ͷΈ
w ԁपͷߴਫ਼ܭࢉʹ֎෦ͷϥΠϒϥϦ͕ඞਢ
©2024 Wantedly, Inc. CJHEFDJNBM ҙਫ਼ͷුಈখϥΠϒϥϦ w ෦తʹਐͰදݱ͍ͯ͠Δ w
͕ͽͬͨΓʹͳΔ w ύϑΥʔϚϯε͋·Γྑ͘ͳ͍ σϑΥϧτHFN w 3VCZ࣌Ͱॲཧܥʹಉࠝ͞Ε͍ͯΔ w 3VCZ͔ΒCVOEMFEHFNʹͳΔΒ͍͠
©2024 Wantedly, Inc. HNQ (.1ٴͼ.1'3ͷ3VCZόΠϯσΟϯά w $Ͱ࣮͞Εͨஶ໊ͳϥΠϒϥϦ w ੑೳંΓࢴ͖ 3VCZόΠϯσΟϯάͷํ͋·Γϝϯς͞Εͯͳ͍
w 3VCZҎ߱ͰCVOEMFJOTUBMMͷڍಈ͕ո͍͠ w ة͏͘3VCZͰ͔͠ಈ͔ͳ͍ԁपܭࢉϓϩάϥϜ͕ੈʹग़Δॴͩͬͨ w 3BDUPSରԠͯ͠ͳ͍
©2024 Wantedly, Inc. ԁपܭࢉϓϩάϥϜͰ(.1Λ͏
©2024 Wantedly, Inc. ༻ͨ͠ϥΠϒϥϦຖͷԁपܭࢉͷൺֱ ສܻ ສܻ ສܻ ສܻ ԯܻ *OUFHFS
#JH%FDJNBM ඵ *OUFHFS (.1' ඵ ඵ ඵ ඵ (.1; (.1' ඵ ඵ ඵ ඵ ඵ
©2024 Wantedly, Inc. ༨ஊेҰੲ https://pc.watch.impress.co.jp/docs/news/yajiuma/636733.html
©2024 Wantedly, Inc. ฒྻԽʹΑΔߴԽͷࢼΈ
©2024 Wantedly, Inc. 3BDUPS 3VCZͰฒྻͳϓϩάϥϜΛهड़͢ΔͨΊͷػߏ w 3VCZ͔Βಋೖ͞Εͨ w "DUPSϞσϧʹجͮ͘ w
3BDUPSؒͰϝοηʔδͷૹड৴͕ߦΘΕΔ͜ͱͰܭࢉ͕ਐΉ ֦ுϥΠϒϥϦجຊNBJO3BDUPSͰ͔͠ಈ͔ͳ͍ w ޓੑͷͨΊ w ֦ுϥΠϒϥϦଆͰ3BDUPSʹରԠ͍ͯ͠ΔࣄΛද໌͢Δඞཁ͕͋Δ w HNQରԠͯ͠ͳ͍
©2024 Wantedly, Inc. ./εϨουεέδϡʔϥ .ݸͷ3VCZεϨουΛ/ݸͷωΠςΟϒεϨουͰ ࣮ߦ͢ΔϞσϧ w ඞཁҎ্ʹωΠςΟϒεϨουΛ࡞Βͳ͍͜ͱͰɺεϨουੜ͕ߴʹͳΔ 3VCZͷ৽ػೳ w
ैདྷݸͷ3VCZεϨουʹରͯ͠ݸͷωΠςΟϒεϨουΛׂΓ͍ͯͯͨ
©2024 Wantedly, Inc. ԁपܭࢉϓϩάϥϜͷฒྻԽ
©2024 Wantedly, Inc. ฒྻԽͷޮՌ ෳͷ$16ίΞΛ׆༻Ͱ͖͍ͯΔ
©2024 Wantedly, Inc. ฒྻԽલޙͰͷԁपܭࢉͷൺֱ ສܻ ສܻ ສܻ ສܻ ԯܻ 3BDUPSಋೖલ
ඵ ඵ ඵ ඵ ඵ 3BDUPSಋೖޙ ඵ ඵ ඵ ඵ ඵ
©2024 Wantedly, Inc. ฒྻԽͰ٫ͬͯ͘ͳͬͨ🤔 3BDUPSͷಋೖ݁Ռ
©2024 Wantedly, Inc. ($͕ϘτϧωοΫʹͳ͍ͬͯΔ ($தશͯͷ3BDUPSͷ࣮ߦ͕ఀࢭͯ͠͠·͏ ฒྻԽͰ͘ͳͬͨݪҼͷߟ
©2024 Wantedly, Inc. ·ͱΊ
©2024 Wantedly, Inc. ·ͱΊ 3VCZʹΑΔԁपܭࢉϓϩάϥϜΛ࣮ ҙਫ਼ܭࢉϥΠϒϥϦຖʹੑೳΛൺֱ w ಛผͳࣄ͕ແ͚ΕHNQΛ͏ͱ͍ 3BDUPSͰฒྻ࣮ߦΛߦ͕ͬͨɺੑೳ৳ͼͳ͔ͬͨ w
ฒྻ࣮ߦͰ͖ͳ͍($͕ϘτϧωοΫʹͳ͍ͬͯΔ w ࠷దԽΛߦ͏લʹTUBDLQSPGͰϘτϧωοΫΛ֬ೝ͠·͠ΐ͏ w ֦ுϥΠϒϥϦ͕3BDUPSʹରԠ͍ͯ͠ͳ͍߹͋ΔͷͰؾΛ͚͍ͨ
More Decks by Masayuki Mizuno
See All by Masayuki Mizuno
OCaml Meeting 2026 in Tokyo
fetburner
0
330
CircleCI ユーザーミートアップ
fetburner
0
240
関数型まつり2026
fetburner
2
1.3k
Rails アプリの docker build を 倍速にした話
fetburner
2
220
Omotesando.rb #110
fetburner
0
260
Continuation is to be continued
fetburner
1
2.7k
callccの実装を読む
fetburner
0
280
RubyでSlackのbotを作ろう
fetburner
0
250
継続オペレータの話
fetburner
0
300
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Amusing Abliteration
ianozsvald
1
390
Exploring anti-patterns in Rails
aemeredith
4
570
We Are The Robots
honzajavorek
0
450
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
640
Design in an AI World
tapps
1
390
Building an army of robots
kneath
307
47k
Designing Experiences People Love
moore
143
24k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
950
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
750
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
3k