1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
harkovskaia [24]
4 years ago
12

Im trying to figure out how to write a program that finds prime factors of a number. I have the following but it only works for

the number 12 for some reason. % this program will determine if an integer is prime and determine
% its prime factors function MAIN clear; clc; % define number(s) to be checked, call function, and print output
N = 12; [answer,primefactors] = primey(N); fprintf('Is %i a prime? %s \n', N, answer) fprintf('The primefactors of %i are: \n' , N) fprintf('%i \n' , primefactors) N = 12; [answer,primefactors] = primey(N); fprintf('Is %i a prime? %s \n', N, answer) fprintf('The primefactors of %i are: \n' , N) fprintf('%i \n' , primefactors) end % end of function MAIN function [answer,primefactors] = primey(N); if mod(N,1)==0 & N/N==1 answer= 'Yes'; else answer= 'No'; end for k= 2:N-1 if mod(N,k)==0 factors(k)=k; end [a,b]= find(factors>0); b primefactors= [1:numel(b)-1] numel(b) for j= 1:numel(b)-1 if mod(b(j),j)==0 primefactors(j)=b(j) end end end end
Computers and Technology
1 answer:
Paladinen [302]4 years ago
7 0
The reason your program isn't working is because you put the n=12 now when you put the other n's in the code it causes it to only work with the number 12
You might be interested in
C2.5 - A group of four pirates has a treasure chest and one unique lock and key for each pirate. Using hardware that is probably
slavikrds [6]

Answer:

Explanation:

All the pirates uses their individual key and lock for the locking down of each the four sides of the lid of to the chest. Among the pirates, if three of them decides to open their latches, they can be able to lift the top by essentially using the fourth (locked) latch as a hinge to open the top. (We have several solutions or ways to do this.)

3 0
3 years ago
You have decided to remove a recently installed feature which method can you use to remove this feature
Aliun [14]
If it is on the desktop screen you just right click on the icon and select delete. from there if you're on a windows computer it goes to your recycle bin then you right click the recycle bin and a little rectangle pops up an in that rectangle it says clear recycle bin and once you press that all of the stuff that was in there is deleted. now if your on a computer that has chrome os installed you just go to the files screen and right click what you want to delete and click delete and it's gone. 
6 0
3 years ago
When might an lcd monitor experience distorted geometry?
horsena [70]

The time when an LCD monitor is experiencing distorted geometry is when there is a presence of the screen into having a display that is not set on the resolution that is supposed to be in native, this is indicative that it is experiencing distorted geometry.

7 0
4 years ago
How do we benefit from this increased interconnectivity?
ankoles [38]
Well we just benefit from it like it just helps as I guess
8 0
3 years ago
True or false As the contents and topics of new magazines change year-to-year, you can see various trends and movements across s
Tamiku [17]

the short answer is true.

The long answer is that magazines can help shape and invent new trends.  like they have time and time again in the past.

Hope this helps

-scav

8 0
3 years ago
Other questions:
  • Determine the number of bytes necessary to store an uncompressed RGB color image of size 640 × 480 pixels using 8, 10, 12 and 14
    11·1 answer
  • Give an example of an outdated memory or storage device what do you think they are outdated
    12·1 answer
  • Careers in information technology deal with
    12·2 answers
  • If your pulse is higher than your Target Heart Rate during exercise, what should you do?
    5·2 answers
  • Create a script that will determine how many of each currency type are needed to make change for a given amount of dollar and ce
    8·1 answer
  • Did brainly.com go down today? i coudlnt get in it
    15·2 answers
  • What is required to become a good critical thinker? Use a process when dealing with a big issue. Practice the right skills over
    9·1 answer
  • como la ciencia y tecnologia ayudan a reducir la contaminacion del aire que respiramos? Muestra algunos ejemplos
    12·1 answer
  • Assume the user types in 7 for x and 2 for y. What is output by the
    6·1 answer
  • A(n) ________ address is the address that external entities use when communicating with your network.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!