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]
2 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]2 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
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
nika2105 [10]

Answer:

The encoding algorithm looks for pairs of characters that appear in the string more than once and replaces each instance of that pair with a corresponding character that does not appear in the string. ... Byte pair encoding is an example of a lossy transformation because it discards some of the data in the original string.

Explanation:

hope it helps!!

6 0
2 years ago
Observe the things at Home in which you are using binary
vazorg [7]

Explanation:

All five things i can come up with her

1. Doors (we either open or close them)

2. Tap (we either open or close the valve)

3.  Electric stove/cooker

4. The lid of containers

5. Shoes/ foot wears(we put them ON or OFF)

7 0
3 years ago
What is gland? mention it's type​
stealth61 [152]

Answer:

Gland is an organ that makes one or more substances, such as hormones, digestive juices, sweat, tears, saliva, or milk.

TYPES OF GLANDS :

ENDOCRINE glands release the substances directly into the bloodstream.

EXOCRINE glands release the substances into a duct or opening to the inside or outside of the body.

BRAINLIEST PLEASE

5 0
2 years ago
Read 2 more answers
The set of rules for how computers talk to one another is called
lianna [129]
Protocol. Like TCP/IP or HTTP etc
6 0
3 years ago
Why do we use if statements in JavaScript?
alexdok [17]

Answer:

The if statement is used to check a condition

8 0
3 years ago
Other questions:
  • What is the name for the individual sections of the ribbon in PowerPoint 20162
    8·1 answer
  • Select the most likely outcome of making only on-time minimum payments to a credit
    11·1 answer
  • The adjustable contact of a potentiometer is placed at the center of its adjustment. If the total resistance is 5 kOhms, what is
    9·1 answer
  • Which of the following is the best example of market censorship
    11·2 answers
  • In addition to format commands that are found in the ribbon, which option is available for more extensive formatting?
    11·1 answer
  • Which of the following is NOT one of the Big 3 Google Applications that we discussed?
    9·2 answers
  • If you copy and paste from someone else's document (such as a website, a friend's paper, an instructor's solutions manual, etc.)
    15·1 answer
  • NEED ANSWER ASAP. CORRECT ANSWER GETS BRAINLIEST! TY
    5·1 answer
  • HELP PLSSS I WILL MARK U!!!!
    10·2 answers
  • I dont uderstand dis my teacher no helping pls help me i need to understand TEch
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!