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:
Answer:
3
Explanation:
Heap sort pick an item from the first or last position in an array and compares it with other items in other positions in the array, swapping position if they meet the condition.
The array above has three maximum items arranged sequentially in the array, this is prove that there have been 3 reheapifications in the array.
KSK Jemens je Jemen jeme this is mine
Answer:
3) 3 44 44
Explanation:
Given data
int [] val = { 3, 10, 44 };
The total number of parameters of given array are 3, so total length of array is also 3.
The indexing of array starts with '0', Therefore the <u>indexes</u> of array with length zero are: {0,1,2}
The value of array at index 0 is = 3
similarly
value at index 1 = 10
value at index 2 = 44
Here, Int i = 1 is storing the value '1' in integer variable i.
In addition to that, any value of index 'i' of an array is selected using array[i].
Therefore,
val[i] is selecting the value of array located at index '1' because i = 1.
val[i] = val[1] = 10
val[i+1] is selecting the value of array located at index 'i+1' that is (1+1) =2
val[i+1] = val[2] = 44
Finally,
val[i] = val[i + 1]; is copying the value placed at index 2 (44) to value placed at index 1 (10). Hence, the output would be {3 44 44}. So 3rd option is correct.