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
░░░░░░░░██████████████████
ELEN [110]

OMG YUHHH

( Also I need one more brainliset until I get expert )

7 0
3 years ago
How many instructions are supercomputers capable of processing in a single second?
liq [111]

Answer:

Trillions

Explanation:

A Supercomputer can process trillions of instructions in a second

6 0
3 years ago
Which exercise can help you prevent Carpel Tunnel Syndrome?
g100num [7]
Make a Fist, hold, and stretch your fingers is the correct answer
8 0
4 years ago
Read 2 more answers
There are several categories of utility programs that were discussed in this unit. For this item, list one. In one to three sent
Zolol [24]

Answer:

Antivirus

Explanation:

The antivirus software is a utility program and what it basically does include: (1) detecting of virus on the computer system (2) bring to the notice of the computer user, the presence of virus on the system.

An example is Avast Antivirus.

6 0
3 years ago
Who was the mvp of the 1989 nba regular season
zvonat [6]
<span>Magic Johnson of the <span>Los Angeles Lakers.</span></span>
7 0
3 years ago
Other questions:
  • _____ performs a real-time lookup of a digital certificate’s status. Group of answer choices Certificate Revocation List (CRL) R
    6·1 answer
  • Whats the relationship between cpu memory and disk​
    10·1 answer
  • Which layer concerns the gateway to the network?
    10·1 answer
  • Once I have entered text into a presentation, how do I modify the font style of the text? Select the text and use options availa
    9·2 answers
  • How does a hard drive work?
    5·1 answer
  • If a football player had to use the restroom during a play what do they do?
    13·1 answer
  • Write the steps involving coping and pasting a file in a folder​
    5·1 answer
  • How to assign some object key values to other name react const.
    7·1 answer
  • Please help!!!
    8·1 answer
  • The goal of _______ is to identify and fix as many errors as possible before units are combined into larger software units.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!