Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in MATLAB/Octave that generates prime numbers and writes them in the following format. (A prime number is a number that is divisible

image text in transcribed

Write a program in MATLAB/Octave that generates prime numbers and writes them in the following format. (A prime number is a number that is divisible only by itself and 1.) The output format is: 3,3 5,5,5 7,7,7,7 Basically one 2, two 3s, three 5s and so on must be printed (separated with commas) and Get N as input from the user and print all prime numbers smaller than or equal to N in You can NOT use isPrime) function of MATLAB Octave. they should be aligned with last row's last character format using Nested For Loops. Sample runs: hul Please enter a nunber5 3.3 5, 5,5 hul Please enter a nunbe15 3.3 5,5,5 7,7,7. 13,13,13,13,13,13 hul Please enter a nunbe 100 3,3 5, 5, 5 7,7,7. 13,13,13,13.13,13 17,17,17,17,17,17,17 19,19.19,19,19,19,19,19 23,23,23,23, 23, 23,23,23,23 29,29,29,29,29, 29, 29,29, 29,29 31,31, 31, 31,31,31, 31,31,31,31,31 37,37,37,37,37,37 37,37,37,37,37,37 41,41,41,41,41,41,41,41, 41,41,41,41,41 43, 43,43,43 43,43,43,43,43, 43,43,43,43,43 53,53, 53 53,53,53 53,53,53,53,53,53,53,53,53,53 9, 59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59 61, 61, 62,61, 61, 61, 61,61,61, 61, 61,61, 61, 61, 61,61,61, 61 71,71,71,71,71,71, 71,71,71,71,71,71,71,71,71,72,71,71,71,7 73,73,73,73,73,73,73,73 73,73,73 73 73,73,73 73,73,73,73,73,73 9,79,79,79,79 79,79,79,79 79,79,79 79, 79,79,79,79,79,79,79 79,79 83,83, 83,83,83,83, 83,83,83,83,83, 83,83,83, 83,83,83,83, B3, 83,83,83, 83 89, 89, 89,89,89, 89, 89,89,89, 89, 89,89,89, 89,89?89,89, 89,89, B9.89, 89,89,89

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago