Question
I have some C code here and curious as to why I am getting duplicate data in reverse format when checking for prime numbers. for
I have some C code here and curious as to why I am getting duplicate data in reverse format when checking for prime numbers.
for example the number 444 .. and other numbers, my output looks like:
But I want it to look like..
I looked at my for loop but cant seem to figure this out. My code is below for you to look at
#include
int main(void){
int N, flag=0, i,YN;
printf("Enter Value: ");
scanf("%d",&N);
printf(" ");
printf("%d = 1 X %d ",N,N);
for (i=2;i if(N%i == 0) { flag = 1; printf("%d = %d X %d ",N,(N/i),i); } } if(flag == 0) printf("%d: PRIME NUMBER ", N); else if (flag == 1) printf("%d:NOT PRIME NUMBER ",N); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started