use MATLAB thank you 3. Write a single program that will count the number of div
ID: 3591449 • Letter: U
Question
use MATLAB thank you
3. Write a single program that will count the number of divisors of each of the following integers: 20, 36, 84, and 96. Use fprintf to output each result in a 4. Write a program that uses nested for loops to produce Pythagorean Triples, positive integers a, b and c that satisfy a2b2 Find all such triples 5. Write a program to perform the following task: Use Matlab to draw a circle of radius 1 centered at the origin and inscribed in a square having vertices (1, form similar to "The number of divisors of 12 is 6." such that 1 S a,b,e 20 and use fprint to produce nicely formatted results. 1) (-1, 1) (-1 -1) and (1,-1). The ratio of the area of the circle to the area of the square is pl: 4 or /4 Hence, if we were to throw darts at the square in a random fashion, the ratio of darts inside the circle to the number of darts thrown should be approximately equal to /4. Write a for loop that will plot 1000 randomly generated points inside the square. Use Matlab's rand command for this task. Each time a random point lands within the unit circle, increment a counter hits. When the for loop terminates, use fprintf to output the ratio darts that land inside the circle to the number of darts thrown. Calculate the relative error in approximating /4 with this ratio.Explanation / Answer
1
for i = [20 36 84 96]
count = 0;
for j = 1:i
if mod(i, j) == 0
count ++;
end
end
fprintf("%d has %d divisors ",i, count);
end
2
for i = 1:20
for j = i:20
for k = j:20
if i^2 + j^2 == k^2
fprintf("%d %d %d are the pythgorean triplet ",i,j,k);
end
end
end
end
We are suppose to write 1 code per request. Since semester exams are round the corner, i solved two for you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.