Code:
#include <math.h>
#include <stdio.h>
int main(){ #include <stdio.h>
int main(){
int i, j, num, num1, isPrime;
scanf("%d %d", &num, &num1);
for(i = 2; i <= (num % num1); i++){
if((num % num1) % i==0){
isPrime = 1;
for(j = 2; j <= i / 2; j++){
if(i % j == 0){
isPrime = 0;
break;
}
}
if(isPrime == 1){
printf("%d ", i);
}
}
}
return 0;
}
Want to ask that is the main prime factor if for example the input 6 12 then the result is 6 but the coding instead has 2 3.
Input:
6 12
Output:
6
Enable GingerCannot connect to Ginger Check your internet connection
or reload the browserDisable in this text fieldEditLog in to edit with GingerLog in to edit with Ginger×Enable GingerCannot connect to Ginger Check your internet connection
or reload the browserDisable in this text fieldEditLog in to edit with GingerLog in to edit with Ginger×