Question

Write in C language

Identical Prime Factors Today is another bad school day for Bibi. Her math teacher just announced that the class exam result

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the accurate code which was executed ,output is in the screeshot shared below please do upvote thank you.

#include<stdio.h>
int calulate(int p,int q)
{
int i,j,isprime,d=0,f=0,k=0,a[1000],b[1000],c[100],res;
//prime factors of p to be stored in array a
for(i=2;i<=p;i++)
{
if(p%i==0)
{
isprime=1;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
isprime=0;
break;
}
}
if(isprime==1){
//if there is a prime factor store it in a
a[d]=i;
d++;
}
}
}
//prime factors of q to be stored in array b
for(i=2;i<=q;i++)
{
if(q%i==0)
{
isprime=1;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
isprime=0;
break;
}
}
if(isprime==1){
//if there is a prime factor store it in b
b[f]=i;
f++;
}
}
}
//to find common elements in array a and b(common prime factors stored in c)
for(i=0;i<d;i++)
{
for(j=0;j<f;j++)
{
if(a[i]==b[j])
{
c[k]=a[i];
k++;
}
}
}
//to find max and min in array c i.e.,common elements array
int small=c[0];
int large=c[0];
for(i=0;i<k;i++)
{
if(c[i]<small)
small=c[i];
if(c[i]>large)
large=c[i];
}
res=small*large;
return res;
}

int main()
{
//t is no of test cases
int t,p,q,i,j,result;
scanf("%d",&t);
while(t!=0)
{
scanf("%d %d",&p,&q);
result=calulate(p,q);
printf("%d",result);
t--;
}
}

---OUTPUT--

בס { main.c int Targe=C[]; 62 for(i=0;i<k;i++) 63 64 if(c[i]<small) 65 small=c[i]; 66 if(c[i]>large) 67 large=c[i]; 68 } 69 r

Add a comment
Know the answer?
Add Answer to:
Write in C language Identical Prime Factors Today is another bad school day for Bibi. Her...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In preparation for the upcoming school year, a teacher looks at raw test scores on the statewide standardized test for the students in her class.

     2. Transforming X values into z-scores In preparation for the upcoming school year, a teacher looks at raw test scores on the statewide standardized test for the students in her class. Instead of looking at the scores relative to the norms in the state, the teacher wants to understand the scores relative to the students who will be in the class. To do so, she decides to convert the test scores into 2-scores relative to the mean and standard deviation of...

  • Mishka is a 16-year-old female, who attends your school. A year ago, Mishka lost both her...

    Mishka is a 16-year-old female, who attends your school. A year ago, Mishka lost both her parents to a murder-suicide (committed by her father) which was hard for her to accept. Mishka was present during the ordeal as she hid behind the sofa as her parents argues. At first, Mishka would tell family members and friends that she would still see her parents and they were not dead. After reality struck, she bargained with God, asking him to return her...

  • Questions points Answer the following questions: An entrepreneurial scientist has invented a supplement that she believes...

    Questions points Answer the following questions: An entrepreneurial scientist has invented a supplement that she believes can enhance short-term memory. She conducts an experiment to test the effect of the supplement on 23 volunteers, 12 of whom are given a placebo and 11 of whom are given the supplement. In analyzing in her study, she obtains a p-value of 0.19. Which of the following is a reasonable interpretation of her results This proves that at most 19% of the time,...

  • Jenna Wright is a new graduate nurse eagerly anticipating her first day of work. She has...

    Jenna Wright is a new graduate nurse eagerly anticipating her first day of work. She has been hired as a nurse in the surgical intensive care unit (ICU) of a large hospital and was selected for a 6-month residency program for new nurses offered by the hospital. Jenna reports to her new nursing unit early on her first day. She waits in the nurses’ station for her assigned preceptor, Betty Jones, who has 20 years of nursing practice experience. Betty...

  • A psychologist wanted to know if students in her class were more likely to cheat if...

    A psychologist wanted to know if students in her class were more likely to cheat if they were low achievers. She divided her 60 students into three groups (low, middle, and high) based on their mean exam score on the previous three tests. She then asked them to rate how likely they were to cheat on an exam if the opportunity presented itself with very limited chance for consequences. The students rated their desire to cheat on a scale ranging...

  • Hi I need some help in C programing class and I doing one of the exercise...

    Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...

  • i have the case study question with the answers but i need help to re-write the...

    i have the case study question with the answers but i need help to re-write the answers. please see the attached files Case Study Analysis (CSF3003) Assessment Description and Requirements CLO1: Case Study 1 Ahmad lef home to study master and PhD in Australia. He has fees for the first semester only. After he arrived to Sydney and settled down, he start looking for a part-time job to save money for the next term. Ahmad has some experience on making...

  • NAME: Class Learning Activity #2 NURSING 110: CONCEPTS & PRACTICE I CONCEPT MODELII: UNIT J: FLUID...

    NAME: Class Learning Activity #2 NURSING 110: CONCEPTS & PRACTICE I CONCEPT MODELII: UNIT J: FLUID AND ELECTROLYTES Case Studies Fluid and Electrolyte Balance Case Study A 51-year-old African American female who was admitted to the hospital 24 hours ago with swollen legs and shortness of breath for 1 week. Weight gain 5 lbs in last 1 week. Patient states she has experienced this before since she was diagnosed with congestive heart failure last year. Patient is anxious and is...

  • Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of...

    Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of physician-centered and collaborative communication. How is the caregiver’s role different in each model? How is the patient’s role different? Answer: Physical-centered communication involves the specialists taking control of the conversation. They decide on the topics of discussion and when to end the process. The patient responds to the issues raised by the caregiver and acts accordingly. On the other hand, Collaborative communication involves a...

  • For each question below select the best answer from those listed and give your reasoning. Your...

    For each question below select the best answer from those listed and give your reasoning. Your reasoning need only be a sentence or two. It is not enough to get the right answer, you must know why it is the right answer. Question 5 Fred's friend claimed that Canadians tend to be jerks. Fred wondered if that was true, and tested it by checking to see how many Canadian jerks he could think of. Fred's cognitive strategy is             ["the availability...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT