SlideShare a Scribd company logo
1 of 16
Поиск простых
чисел
Подготовили :
Гаризан Таисия
Ангельчева Людмила
Ангельчева Евгения
Франжев Дмитрий
Братунова Людмила
Кирчиогло Денис
Гайдарлы Ирина
Учитель:
Драган Ник. Ник.
Вводим числа: Получаем:
n:integer; m:integer;
(границы интервала)
n=1 m=10
n m На экране выводятся
1 10 2, 3, 5, 7
1 100 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61
67 71 73 79 83 89, 97
1 1000 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59
61 67 71 73 79 83 89 97 101 103 107 109 113 127 131
137 139 149 151 157 163 167 173 179 181 191 193 197 199
211 223 227 229 233 239 241 251 257 263 269 271 277 281
283 293 307 311 313 317 331 337 347 349 353 359 367 373
379 383 389 397 401 409 419 421 431 433 439 443 449 457
461 463 467 479 487 491 499 503 509 521 523 541 547 557
563 569 571 577 587 593 599 601 607 613 617 619 631 641
643 647 653 659 661 673 677 683 691 701 709 719 727 733
739 743 751 757 761 769 773 787 797 809 811 821 823 827
829 839 853 857 859 863 877 881 883 887 907 911 919 929
Принцип полного перебора
Общий вид:
For i:=1 to k do
if ReshenieVozm(s[i])
then Obrabotka (s[i]);
Проверяем все потенциальные
решения, отбрасывая те,
которые не удовлетворяют
условиям задачи. Далее
сохраняем лучшее решение,
найденное на данный момент.
Когда поиск закончен, выдаем
решение.
Главный блок:
1. Вводим первое и
конечное число интервала.
После запускаем цикл от n
до m, компьютер доходит
до названия фун-ции Prost(i)
и запускает ее, отправляя
значение числа.
Функция
1. Проверка, если число
меньше двух, то
присваеваем значению ф-
ии false, т.к. Первое простое
число это 2.
Функция
2. Присваиваем значению ф-ии true.
(предположим, что число простое)
3. Данная строчка
производит цикл от 2-х до половины
проверяемого числа. (div, т.е.
Берется только целая часть)
4. Так мы делим а
(проверяемое число) на числа из
интервала от 2-х до a/2.
5. Делаем простую проверку,
если число делится нацело,
значит оно не простое,
присваимаем ф-ии false и при
помощи оператора break
останавливаем цикл сразу, как
только нашли первый делитель.
пример:
У нас число 10.
Цикл от 2-х до 5
Проверка: 10/2 остаток 0, число не
простое, break (стоп, выйди из
цикла).
Что было бы без break?
Программа продолжала бы делить число и
проверять остаток лишний раз.
А если остается остаток, то на
экране выводится это число.
 Когда программа
выходит из функции, она
возвращается в главный
блок:
 Здесь выполняется
проверка (не забываем,
что функция возвращает
ответ типа Boolean)
 Если ф-я true, тогда пиши
на экран число.
Реализация алгоритма(программа)
Тестирование программы
[n=1..m=10]
[n=1..m=100]
[n=1..m=1000]
Анализ результатов
После проделанной программы мы
можем сделать следующие выводы :
1)Эта программа позволяет нам найти числа, которые делятся только на 1
и на себя.
2) Количество полученных решений зависит от интервала входных данных n
и m (Чем больше интервал ,тем количество чисел увеличивается)
3)Можно заметить, что
все числа выведенные
на экран программой-
нечетные, кроме 2.
(нет, не все нечетные числа
простые)
Зависимость времени выполнения алгоритма
от входных данных
m t
10 0
100 31
1000 125
Прямопропорциональная зависимость

More Related Content

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)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 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd 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 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 IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO 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)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 2024How 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 InsightsSocial 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 2024Trends 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 summary5 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 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 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 IntentGoogle'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 How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe 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...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Prostoe poisk

  • 1. Поиск простых чисел Подготовили : Гаризан Таисия Ангельчева Людмила Ангельчева Евгения Франжев Дмитрий Братунова Людмила Кирчиогло Денис Гайдарлы Ирина Учитель: Драган Ник. Ник.
  • 2. Вводим числа: Получаем: n:integer; m:integer; (границы интервала) n=1 m=10 n m На экране выводятся 1 10 2, 3, 5, 7 1 100 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89, 97 1 1000 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929
  • 3. Принцип полного перебора Общий вид: For i:=1 to k do if ReshenieVozm(s[i]) then Obrabotka (s[i]);
  • 4. Проверяем все потенциальные решения, отбрасывая те, которые не удовлетворяют условиям задачи. Далее сохраняем лучшее решение, найденное на данный момент. Когда поиск закончен, выдаем решение.
  • 5. Главный блок: 1. Вводим первое и конечное число интервала. После запускаем цикл от n до m, компьютер доходит до названия фун-ции Prost(i) и запускает ее, отправляя значение числа. Функция 1. Проверка, если число меньше двух, то присваеваем значению ф- ии false, т.к. Первое простое число это 2.
  • 6. Функция 2. Присваиваем значению ф-ии true. (предположим, что число простое) 3. Данная строчка производит цикл от 2-х до половины проверяемого числа. (div, т.е. Берется только целая часть)
  • 7. 4. Так мы делим а (проверяемое число) на числа из интервала от 2-х до a/2. 5. Делаем простую проверку, если число делится нацело, значит оно не простое, присваимаем ф-ии false и при помощи оператора break останавливаем цикл сразу, как только нашли первый делитель. пример: У нас число 10. Цикл от 2-х до 5 Проверка: 10/2 остаток 0, число не простое, break (стоп, выйди из цикла). Что было бы без break? Программа продолжала бы делить число и проверять остаток лишний раз. А если остается остаток, то на экране выводится это число.
  • 8.  Когда программа выходит из функции, она возвращается в главный блок:  Здесь выполняется проверка (не забываем, что функция возвращает ответ типа Boolean)  Если ф-я true, тогда пиши на экран число.
  • 9.
  • 14. Анализ результатов После проделанной программы мы можем сделать следующие выводы : 1)Эта программа позволяет нам найти числа, которые делятся только на 1 и на себя. 2) Количество полученных решений зависит от интервала входных данных n и m (Чем больше интервал ,тем количество чисел увеличивается) 3)Можно заметить, что все числа выведенные на экран программой- нечетные, кроме 2. (нет, не все нечетные числа простые)
  • 15. Зависимость времени выполнения алгоритма от входных данных m t 10 0 100 31 1000 125