Submit Search
Upload
エラトステネスの篩を用いた素数判定 2019 - 05 - 08
•
Download as PPTX, PDF
•
0 likes
•
93 views
Nmimineko
Follow
情処LTで発表したスライドを一部編集したものです
Read less
Read more
Engineering
Report
Share
Report
Share
1 of 20
Download now
Recommended
数学コンサルタント:横田秀珠式100までの素数を見つける方法⇔エラトステネスの篩
数学コンサルタント:横田秀珠式100までの素数を見つける方法⇔エラトステネスの篩
新潟コンサルタント横田秀珠
「パネルディスカッション 行動経済学の教育」 竹内幹(一橋大学) 資料 3/4
「パネルディスカッション 行動経済学の教育」 竹内幹(一橋大学) 資料 3/4
evidence8money
中華圏とのライセンスイン・アウトの実務と可能性
中華圏とのライセンスイン・アウトの実務と可能性
CLARA ONLINE, Inc.
一攫
一攫
Yasukazu Kawasaki
九九の表についての研究
九九の表についての研究
Tomoyoshi HIRATA
nextProbablePrime() について
nextProbablePrime() について
Kazuro Fukuhara
Business Regulations / Business Law Notes
Business Regulations / Business Law Notes
Bilal's Academy
整数クイズへの誘い
整数クイズへの誘い
俊介 後藤
Recommended
数学コンサルタント:横田秀珠式100までの素数を見つける方法⇔エラトステネスの篩
数学コンサルタント:横田秀珠式100までの素数を見つける方法⇔エラトステネスの篩
新潟コンサルタント横田秀珠
「パネルディスカッション 行動経済学の教育」 竹内幹(一橋大学) 資料 3/4
「パネルディスカッション 行動経済学の教育」 竹内幹(一橋大学) 資料 3/4
evidence8money
中華圏とのライセンスイン・アウトの実務と可能性
中華圏とのライセンスイン・アウトの実務と可能性
CLARA ONLINE, Inc.
一攫
一攫
Yasukazu Kawasaki
九九の表についての研究
九九の表についての研究
Tomoyoshi HIRATA
nextProbablePrime() について
nextProbablePrime() について
Kazuro Fukuhara
Business Regulations / Business Law Notes
Business Regulations / Business Law Notes
Bilal's Academy
整数クイズへの誘い
整数クイズへの誘い
俊介 後藤
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
エラトステネスの篩を用いた素数判定 2019 - 05 - 08
1.
エラトステネスの篩 を用いた素数判定 3年5組 **** TwitterID @3_3_nk
2.
自己紹介 ■ 数学大好き18歳 ■ とうとうTwitterのフォロワーが 1000人に
ありがとうございます ■ AtCoderのレートが緑になった うれしい
3.
そもそも「素数」とは ■ 「1」と「その数自身」の2つ以外に約数がない自然数の こと ■ つまり、「自然数
かつ 約数の個数が𝟐個」ならば素数 この定義が何よりも優先されると考えてください
4.
「素数判定」って何ですか ■ ある数が、素数か素数でないか判定すること ■ 素数でない数のことを合成数といいます(一部例外あり) ■
今回は「効率よく素数判定しよう」を主軸に話します 「計算量を少なくしよう」ということ
5.
100未満の自然数を素数判定しよう ■ 条件に当てはまる数はだいたい 100個ある 1つ1つ素数判定していくのは 大変 ■
ここで登場するのが「エラトス テネスの篩」というアルゴリズ ム
6.
エラトステネスの篩(ふるい)とは ■ N以下のすべての自然数に対して、素数か素数でないかを 比較的高速に判定することができる 1. 2から𝑁までの整数を並べる 2.
一番小さい数を𝑝と置き、𝑝以外の𝑝の倍数をすべて消す 3. 上記の操作を 𝑝 > 𝑁 となるまで繰り返す ■ 証明は省略(ググったらいっぱい出てくるので)
7.
実際にエラトステネスの篩を やってみよう!
8.
1.𝑁までの自然数を一通り書き出す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
9.
2.一番小さい2を残す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
10.
3.2の倍数をすべて消す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
11.
4.次に小さい3を残す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
12.
5.3の倍数をすべて消す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
13.
6.5を残し、5の倍数をすべて消す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
14.
7.7を残し、7の倍数をすべて消す 2 3 4
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
15.
8.11 > 100
なので残りは全て素数 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
16.
どのくらい早いのか? ■ 愚直に計算した場合、𝑂 𝑁
𝑁 かかる ■ エラトステネスの篩を用いて計算した場合、 𝑂(𝑁 log log 𝑁) かかる ■ 𝑁が十分大きい時 𝑂 𝑁 𝑁 > 𝑂 𝑁 log log 𝑁 なので、 エラトステネスの篩を用いて計算したほうが計算量が 少なく済む!
17.
エラトステネスの篩を実装する ■ 長さ𝑁 +
1の配列を用意し、各要素に対して 𝑖(0 ≤ 𝑖 ≤ 𝑁) が素数なら ”true” を、非素数なら ”false” を代入する ■ 0, 1 は非素数なのであらかじめ “false” を代入しておく ■ 𝑖 について 𝑁 回ループする 𝑖 が “true” なら、2𝑖, 3𝑖, 4𝑖, … に “false” を代入する
18.
実装する • C++での実装例 void seive(){ for(int
i = 0; i <= N; i ++) num[i] = true; num[0] = false; num[1] = false; for(int i = 0; i <= sqrt(N); i ++){ if(i == true){ for(int j = i * i; j <= N; j += i){ num[j] = false; } } } }
19.
結論 ■ 普通に計算するよりめちゃ くちゃ早い! ■ 実装するのも簡単 ■
名前は正しく覚えてくださ い!!!
20.
エラトステネスの篩 を用いた素数判定 3年5組 **** TwitterID @3_3_nk
Editor's Notes
>タイトルなんですが、素数判定
約数とは、その数を割り切るような自然数のこと
Download now