1 answer

*** Write a function called circular_primes that finds the number of circular prime numbers smaller than...

Question:

*** Write a function called circular_primes that finds the number of circular prime numbers smaller
than n, where n is a positive integer scalar input argument. For example, the number, 197, is a circular
prime because all rotations of its digits: 197, 971, and 719, are themselves prime. For instance, there are
thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. It is important to emphasize
that rotation means circular permutation not all possible permutations.

I need matlab code


Answers

Copyable Code:

function [cprime] = circular_primes(number)
cprime=0;
cnewprime=[];
% this is for determine all primes in < n
p=primes(number-1);
nPrime=length(p);
fprintf('The circular prime numbers are: ');
% check circularShift for given prime is circular or not
for i=1:nPrime
% for checking the every digits in prime
number=p(i);
for a=1:findDigits(p(i))
digit(a)=mod(number,10);
number=floor(number/10);
end
%for combine permutations
flag=true;
for a=1:length(digit)
answer=circshift(digit,[1,1]);
digit=answer;
num=0;
for k=1:length(digit)
num=num+10^(k-1) * digit(k);
end
num;
%here check it is prime or not in each permutation
if ~isprime(num)
flag=false;
end
end
%the given prime is circular if every permutations is prime
if flag==true
cprime=cprime+1;
cnewprime=[cnewprime,p(i)];
end
end
%for display the circular prime number
disp(cnewprime);
end
%this function for find digits in a given number
function fd= findDigits(B)
fd=floor(log10(abs(B)+1)) + 1;
end
fprintf('Total number of circular prime number in the given range is: %d\n',circular_primes(100));

.

Similar Solved Questions

1 answer
1. How many GRAMS of nitrogen are present in 1.55 moles of dinitrogen tetrafluoride, N2F4?   _______grams...
1. How many GRAMS of nitrogen are present in 1.55 moles of dinitrogen tetrafluoride, N2F4?   _______grams 2. How many MOLES of fluorine are present in 1.08 grams of dinitrogen tetrafluoride?   _________moles 3.The percent by mass of copper(I) in Cu2SO3 is __________%. 4. Calculat...
1 answer
A circular conducting wire with a radius of 25.0 cm has a current 0.680 A flowing...
A circular conducting wire with a radius of 25.0 cm has a current 0.680 A flowing through it. The magnetic field 6.25 T acts at an angle of 25.9° as shown in the picture. B R - Part A - Find the net torque acting on the wire. 0 1,46x10-2 Nm 0 5.83 Nm 0 5.83x10-2 Nm 0 0.365 Nm 0 3650 Nm...
1 answer
Converge/ diverge 1 ettrmine wkether o it cauv fuid ts value. Cony oiv COSX + sn
converge/ diverge 1 ettrmine wkether o it cauv fuid ts value. Cony oiv COSX + sn...
1 answer
PLzzzz help me with this!!1 3. 0/1 points |I Previous Answers SerPSE10 22.3.OP005.ctx. My Notes Ask...
PLzzzz help me with this!!1 3. 0/1 points |I Previous Answers SerPSE10 22.3.OP005.ctx. My Notes Ask Your Teacher You are working in a biology lab during your summer break. Your supervisor asks you to perform an experiment to find the effective spring constant (in N/m) of a partial molecule of DNA de...
1 answer
Question 8 (1 point) Ms. Manners Catering (MMC) stock pays an annual dividend of $3.2 per...
Question 8 (1 point) Ms. Manners Catering (MMC) stock pays an annual dividend of $3.2 per share. If investors require a 10 percent rate of return, what should be the price of MMC stock?(show your work)...
1 answer
2. (a) A 12-tooth pinion has AGMA standard full-depth involute teeth with diametral pitch of 4...
2. (a) A 12-tooth pinion has AGMA standard full-depth involute teeth with diametral pitch of 4 in and pressure angle 25. Determine the pitch diameter of both the pinion and the gear, number of teeth of gear, and center distance between gear shafts. The reduction speed ratio is 7. (b) what is the sig...
1 answer
You are making an artificial eukaryotic chromosome, and you plan to add two copies of this...
You are making an artificial eukaryotic chromosome, and you plan to add two copies of this chromosome to the nucleus of a diploid yeast cell. What characteristics would you include in the chromosome to make sure that the chromosome pair is (a) properly replicated and (b) passed to each daughter cell...
1 answer
Budgeted income statement and supporting budgets for three months Newport Inc. gathered the following data for...
Budgeted income statement and supporting budgets for three months Newport Inc. gathered the following data for use in developing the budgets for the first quarter June, July, August) of its fiscal year: a. Estimated sales at $36 per unit: June 300,000 units July August September 400,000 units 500,00...
1 answer
Epinephrine signaling , like that of insulin, is a multi-step pathway with several amplification steps. Identify...
Epinephrine signaling , like that of insulin, is a multi-step pathway with several amplification steps. Identify each of the steps below as either allosteric activation or enzymatic. Abbreviations: Epi (epinephrine),  β2AR (β2 adrenergic receptor), R2C2 (subunit composition of pr...
1 answer
1. Using question 12 (delaying major purchases) as the response variable (Y) compute a regression model...
1. Using question 12 (delaying major purchases) as the response variable (Y) compute a regression model with the following questions 9, 25 (gender: males as 0 and females coded as 1) as your predictor variables. You will have to use the data set Economic Gun Legislation Survey Regression Exercise po...
1 answer
How many moles of H2O2 were consumed? Can you make comments during each step of your...
How many moles of H2O2 were consumed? Can you make comments during each step of your solution? Decomposition of Hydrogen Peroxide Name Match each of the following components in this lab to its intended purpose safety glasses/goggles catalyzes the reaction water initially in the 100ml graduated cylin...
1 answer
(9 points) Difficulty (3/5) A S20x75 I-beam is loaded and supported as shown, with F =...
(9 points) Difficulty (3/5) A S20x75 I-beam is loaded and supported as shown, with F = 7.8 kip. The dirmensions on the figure are a = 5 6 ft and b 1.96 ft Accounting for the self weight of the beam, determine the reactions at the support and the maximum stress in the beam. Report upward forces and c...
1 answer
I'm not sure if it's correct Question 5 The distribution reservoirs are used in System) of...
I'm not sure if it's correct Question 5 The distribution reservoirs are used in System) of water distribution networks for urban water supply schemes. Large distribution...
1 answer
O Assignment Score: 2386/2500 Resources can Online Check Answer Question 18 of 25 > What is...
O Assignment Score: 2386/2500 Resources can Online Check Answer Question 18 of 25 > What is the chemical formula for the compound formed between chromium(III) and fluorine? chemical formula: What is the chemical formula for the compound formed between chromium(III) and selenium? chemical formula:...
1 answer
Requirements e1. Compute Austin Airlines's first-year depreciation expense on the plane using the following methods: a....
Requirements e1. Compute Austin Airlines's first-year depreciation expense on the plane using the following methods: a. Straight-line b. Units-of-production c. Double-declining-balance 2. Show the airplane's book value at the end of the first year for all three methods. ir Print Done a on th...
1 answer
2. (3 points) The position of an object connected to a spring varies with time according...
2. (3 points) The position of an object connected to a spring varies with time according to the expression x = (7.5 cm)cos (0.25 t) (a) Find the (i) period, (ii) frequency and (iii) amplitude of the oscillations. (b) Write down the expressions for time dependent (i) velocity and (ii) acceleration of...