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
After you have located a program name from the Start menu, in order to create a shortcut on the desktop.
aniked [119]

Answer: wut am I suppose to do

Explanation: thx for the free points :)

5 0
3 years ago
Question #5<br> How does the computer decide which path to follow in a selection control structure?
konstantin123 [22]

Answer:

to answer your question in my thoughts the material of the coding structure helps the software or the cpu translate or guide the programming  .

Explanation:

6 0
3 years ago
You arrive to an intersection with traffic
just olya [345]
What were you thinking there?
6 0
3 years ago
How are appointments scheduled in medisoft
qaws [65]
Appointments scheduled in medisoft is based on how
•How quickly making, copying, or changing appointments
•Track treatment room schedules
•Instantaneously search all providers for next available time slot
•Add patients to an appointment wait list

4 0
4 years ago
How many yards must you run to complete a 100 meter dash?
ddd [48]
103 yards in a 100 meter dash
<span />
4 0
3 years ago
Read 2 more answers
Other questions:
  • Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
    5·2 answers
  • My 2 in 1 laptop/tablet
    13·1 answer
  • Of the key reasons for creating organizational units which of the following is not one of them?
    13·1 answer
  • . Write a C++ Code to get a multiline statement Str1 from a user with a ‘$’ as return character (Hint:
    6·1 answer
  • Is the practice of downloading and distributing copyrighted content digitally without permission??
    14·1 answer
  • Which of the examples is part of client-side code?
    12·1 answer
  • Tasavvuf kelimesi soyut bir kelimedir.​
    7·1 answer
  • Question #5
    15·2 answers
  • This is really dumb but can someone help me find these memes? I can’t remember what they’re called but I remember how they went
    14·2 answers
  • Which function works best when you need to remove an element at a specific index in a list?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!