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
slavikrds [6]
3 years ago
5

circular_prime A number is called a circular prime if all rotations of its digits form a prime. For example, the number 197 is a

circular prime because all possible rotations of its digits: (197, 971, 719) are prime numbers. Write a program that reads in an integer 1 en 10^5 as input and prints True if n is a circular prime and False otherwise.
Computers and Technology
1 answer:
Lilit [14]3 years ago
3 0

Answer:

function out=circular_primes(no)

prim=primes(no);% find the all prime number till the given number

pr=0;

nos=[];

po=[];

for p=1:length(prim)

   n=prim(p); % picking up each prime no one by one

   n=num2str(n);% change into string for rotation of no

   d=length(n); % length of string

   if d>1          % take nos greater than 10 beacuase below 10 no need for rotation

       for h=1:d

           a=n(1);

           for r=1:d % for rotation right to left

               if r==d  5 % for the last element of string

                   n(d)=a;

               else

               n(r)=n(r+1); %shifting

               end

           end

           

       s=str2num(n); % string to number

       nos=[nos,s]; % store rotated elements in array

       end

       if nos(end)==no   %if given no is also a circular prime we need smaller

           break;

       end

       for gr=1:length(nos) % checking rotated nos are prime or not

           p1=isprime(nos(gr));

           po=[po,p1];    %storing logical result in array

       end

           if sum(po(:))==length(nos) %if all are prime the length and sum are must be equal

               

               pr=pr+1;

               out=pr;

           else

               out=pr;

           end

       po=[];

       nos=[];

   else  

       s=str2num(n); %numbers less than 10

       f=isprime(s);

       if f==1

           pr=pr+1;

           out=pr;

       else

           out=pr;

       end

   end

       

      end

end

Explanation:

You might be interested in
Enterprise application integration (eai) software enables users to model the business processes and interactions that should occ
Tanya [424]
Sorry i need 50 points

6 0
3 years ago
Select all that apply.
professor190 [17]
Social worker and legal aid worker

4 0
3 years ago
Read 2 more answers
Name three actions you should take if you believe you’ve been victimized by crimeware or online fraud
allochka39001 [22]

Try restating system software and delete anything that may have caused the online fraud then remove all credit cards and info on the device. Tell the authorities and get a new device and email with a software protector. When doing this DO NOT DO WHAT YOU ORIGINALLY DID TO GET VICTIMIZED AND (DON'T TRY TO SIGN INTO YOUR PREVIOUS EMAIL ON A NEW DEVICE)  

4 0
3 years ago
Read 2 more answers
Select the correct answer.
Vedmedyk [2.9K]
D because of the sun
6 0
3 years ago
What is data mining ​
Vesna [10]

Answer:

Data mining is a process of extracting and discovering patterns in large data sets involving methods at the intersection of machine learning, statistics, and database systems.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Of the different IRT roles, the _______________ is head of the team and issues the ultimate call regarding how to respond to an
    15·1 answer
  • Write a program that inputs a line of text and uses a stack object to print the line reversed.
    14·1 answer
  • There are several methods of updating information and data on a webserver. We must consider who performs those updates upfront w
    9·2 answers
  • How are engineers are related to technology
    13·1 answer
  • Ricardo twists his ankle at work but does not immediately realize that he is injured because his ankle is not sore or swollen, a
    5·1 answer
  • If you used a peach as a model of an animal cell, what would the peach's skin represent? A.nucleus B.cell wall C.cytoplasm D.cel
    10·2 answers
  • How many people on here are doing edmentum online
    11·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • What is net pay?<br> What is net pay?
    11·2 answers
  • What is game development​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!