SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Plus 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
 

Plus 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
 

Dernier

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Dernier (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

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