SlideShare uma empresa Scribd logo
1 de 1
MATLAB: Write a function whose input is a positive integer n, and whose output is the nth
prime number. Then, write a script that calls this function to output the sum of the first n prime
numbers and the product of the first n prime numbers.
Solution
function x=NthPrime(n)
sum=0
n=0
if size(x)>2
for x
if(isprime(x))<n
sumprime=sum(prime(n)
productprime=product(prime(n))
end

Mais conteúdo relacionado

Mais de maryi15

Name two specific non-manufacturing costs that might be included in ac.docx
Name two specific non-manufacturing costs that might be included in ac.docxName two specific non-manufacturing costs that might be included in ac.docx
Name two specific non-manufacturing costs that might be included in ac.docxmaryi15
 
Name seven (7) characteristics that impact the design of a foundation-.docx
Name seven (7) characteristics that impact the design of a foundation-.docxName seven (7) characteristics that impact the design of a foundation-.docx
Name seven (7) characteristics that impact the design of a foundation-.docxmaryi15
 
Name some of the problems the ARC has encountered with handling donati.docx
Name some of the problems the ARC has encountered with handling donati.docxName some of the problems the ARC has encountered with handling donati.docx
Name some of the problems the ARC has encountered with handling donati.docxmaryi15
 
Name and briefly describe three different uses for interrupts-Solution.docx
Name and briefly describe three different uses for interrupts-Solution.docxName and briefly describe three different uses for interrupts-Solution.docx
Name and briefly describe three different uses for interrupts-Solution.docxmaryi15
 
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docx
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docxName Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docx
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docxmaryi15
 
nalyze and explain why it is important for management to provide emplo.docx
nalyze and explain why it is important for management to provide emplo.docxnalyze and explain why it is important for management to provide emplo.docx
nalyze and explain why it is important for management to provide emplo.docxmaryi15
 
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docx
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docxmyctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docx
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docxmaryi15
 
Mrs- F has invited several wives of delegates to the United Nations fo.docx
Mrs- F has invited several wives of delegates to the United Nations fo.docxMrs- F has invited several wives of delegates to the United Nations fo.docx
Mrs- F has invited several wives of delegates to the United Nations fo.docxmaryi15
 
Match the Interface with its most efficient implementation- Map- TreeM.docx
Match the Interface with its most efficient implementation- Map- TreeM.docxMatch the Interface with its most efficient implementation- Map- TreeM.docx
Match the Interface with its most efficient implementation- Map- TreeM.docxmaryi15
 
My Notes Ask Your Teach Two identical diverging lenses are separated b.docx
My Notes Ask Your Teach Two identical diverging lenses are separated b.docxMy Notes Ask Your Teach Two identical diverging lenses are separated b.docx
My Notes Ask Your Teach Two identical diverging lenses are separated b.docxmaryi15
 
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docx
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docxMy Notes Ask Your Tesch away using a camera that has a lens with a foc.docx
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docxmaryi15
 
MUS101 Women made huge steps for being recognized musically in the Rom.docx
MUS101 Women made huge steps for being recognized musically in the Rom.docxMUS101 Women made huge steps for being recognized musically in the Rom.docx
MUS101 Women made huge steps for being recognized musically in the Rom.docxmaryi15
 
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docx
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docxMUS101 What musical techniques did Vivaldi use in La Primavera to depi.docx
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docxmaryi15
 
MUS101 Women made huge steps for being recognized musically in the Rom (1).docx
MUS101 Women made huge steps for being recognized musically in the Rom (1).docxMUS101 Women made huge steps for being recognized musically in the Rom (1).docx
MUS101 Women made huge steps for being recognized musically in the Rom (1).docxmaryi15
 
Music 101 How does an Oratorio differ from an Opera- How is it similar.docx
Music 101 How does an Oratorio differ from an Opera- How is it similar.docxMusic 101 How does an Oratorio differ from an Opera- How is it similar.docx
Music 101 How does an Oratorio differ from an Opera- How is it similar.docxmaryi15
 
MUS101 Discuss the importance of the Patronage System in the Classical.docx
MUS101 Discuss the importance of the Patronage System in the Classical.docxMUS101 Discuss the importance of the Patronage System in the Classical.docx
MUS101 Discuss the importance of the Patronage System in the Classical.docxmaryi15
 
Multiple choice- circle the best responses below a) The element most e.docx
Multiple choice- circle the best responses below a) The element most e.docxMultiple choice- circle the best responses below a) The element most e.docx
Multiple choice- circle the best responses below a) The element most e.docxmaryi15
 
Monitor is one of the concurrency mechanisms- It is usually a piece of.docx
Monitor is one of the concurrency mechanisms- It is usually a piece of.docxMonitor is one of the concurrency mechanisms- It is usually a piece of.docx
Monitor is one of the concurrency mechanisms- It is usually a piece of.docxmaryi15
 
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docx
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docxMini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docx
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docxmaryi15
 
Modern comparative economists would object to the definition of econom.docx
Modern comparative economists would object to the definition of econom.docxModern comparative economists would object to the definition of econom.docx
Modern comparative economists would object to the definition of econom.docxmaryi15
 

Mais de maryi15 (20)

Name two specific non-manufacturing costs that might be included in ac.docx
Name two specific non-manufacturing costs that might be included in ac.docxName two specific non-manufacturing costs that might be included in ac.docx
Name two specific non-manufacturing costs that might be included in ac.docx
 
Name seven (7) characteristics that impact the design of a foundation-.docx
Name seven (7) characteristics that impact the design of a foundation-.docxName seven (7) characteristics that impact the design of a foundation-.docx
Name seven (7) characteristics that impact the design of a foundation-.docx
 
Name some of the problems the ARC has encountered with handling donati.docx
Name some of the problems the ARC has encountered with handling donati.docxName some of the problems the ARC has encountered with handling donati.docx
Name some of the problems the ARC has encountered with handling donati.docx
 
Name and briefly describe three different uses for interrupts-Solution.docx
Name and briefly describe three different uses for interrupts-Solution.docxName and briefly describe three different uses for interrupts-Solution.docx
Name and briefly describe three different uses for interrupts-Solution.docx
 
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docx
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docxName Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docx
Name Problem # 2 ( 2e prs ) anging not straight down- but at an angle.docx
 
nalyze and explain why it is important for management to provide emplo.docx
nalyze and explain why it is important for management to provide emplo.docxnalyze and explain why it is important for management to provide emplo.docx
nalyze and explain why it is important for management to provide emplo.docx
 
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docx
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docxmyctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docx
myctfitemView-offset-next&assignmentProblemID-- 103375190 Based on pos.docx
 
Mrs- F has invited several wives of delegates to the United Nations fo.docx
Mrs- F has invited several wives of delegates to the United Nations fo.docxMrs- F has invited several wives of delegates to the United Nations fo.docx
Mrs- F has invited several wives of delegates to the United Nations fo.docx
 
Match the Interface with its most efficient implementation- Map- TreeM.docx
Match the Interface with its most efficient implementation- Map- TreeM.docxMatch the Interface with its most efficient implementation- Map- TreeM.docx
Match the Interface with its most efficient implementation- Map- TreeM.docx
 
My Notes Ask Your Teach Two identical diverging lenses are separated b.docx
My Notes Ask Your Teach Two identical diverging lenses are separated b.docxMy Notes Ask Your Teach Two identical diverging lenses are separated b.docx
My Notes Ask Your Teach Two identical diverging lenses are separated b.docx
 
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docx
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docxMy Notes Ask Your Tesch away using a camera that has a lens with a foc.docx
My Notes Ask Your Tesch away using a camera that has a lens with a foc.docx
 
MUS101 Women made huge steps for being recognized musically in the Rom.docx
MUS101 Women made huge steps for being recognized musically in the Rom.docxMUS101 Women made huge steps for being recognized musically in the Rom.docx
MUS101 Women made huge steps for being recognized musically in the Rom.docx
 
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docx
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docxMUS101 What musical techniques did Vivaldi use in La Primavera to depi.docx
MUS101 What musical techniques did Vivaldi use in La Primavera to depi.docx
 
MUS101 Women made huge steps for being recognized musically in the Rom (1).docx
MUS101 Women made huge steps for being recognized musically in the Rom (1).docxMUS101 Women made huge steps for being recognized musically in the Rom (1).docx
MUS101 Women made huge steps for being recognized musically in the Rom (1).docx
 
Music 101 How does an Oratorio differ from an Opera- How is it similar.docx
Music 101 How does an Oratorio differ from an Opera- How is it similar.docxMusic 101 How does an Oratorio differ from an Opera- How is it similar.docx
Music 101 How does an Oratorio differ from an Opera- How is it similar.docx
 
MUS101 Discuss the importance of the Patronage System in the Classical.docx
MUS101 Discuss the importance of the Patronage System in the Classical.docxMUS101 Discuss the importance of the Patronage System in the Classical.docx
MUS101 Discuss the importance of the Patronage System in the Classical.docx
 
Multiple choice- circle the best responses below a) The element most e.docx
Multiple choice- circle the best responses below a) The element most e.docxMultiple choice- circle the best responses below a) The element most e.docx
Multiple choice- circle the best responses below a) The element most e.docx
 
Monitor is one of the concurrency mechanisms- It is usually a piece of.docx
Monitor is one of the concurrency mechanisms- It is usually a piece of.docxMonitor is one of the concurrency mechanisms- It is usually a piece of.docx
Monitor is one of the concurrency mechanisms- It is usually a piece of.docx
 
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docx
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docxMini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docx
Mini Corp- acquires a patent from Maxi Co- in exchange for 2-500 share.docx
 
Modern comparative economists would object to the definition of econom.docx
Modern comparative economists would object to the definition of econom.docxModern comparative economists would object to the definition of econom.docx
Modern comparative economists would object to the definition of econom.docx
 

Último

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 

Último (20)

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

MATLAB- Write a function whose input is a positive integer n- and whos.docx

  • 1. MATLAB: Write a function whose input is a positive integer n, and whose output is the nth prime number. Then, write a script that calls this function to output the sum of the first n prime numbers and the product of the first n prime numbers. Solution function x=NthPrime(n) sum=0 n=0 if size(x)>2 for x if(isprime(x))<n sumprime=sum(prime(n) productprime=product(prime(n)) end