Thread: Prime Factor

  1. #1
    Registered User
    Join Date
    Jul 2020
    Posts
    6

    Prime Factor

    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×
    Attached Images Attached Images Prime Factor-20200729_231901-jpg 

  2. #2
    Registered User
    Join Date
    Jul 2020
    Posts
    6
    Enable GingerCannot connect to Ginger Check your internet connection
    or reload the browserDisable in this text fieldEditEdit in GingerEdit in Ginger×

  3. #3
    Registered User
    Join Date
    Jul 2020
    Posts
    6
    And So if you are looking for prime numbers between the two numbers, what your complaint about 2 * 3 = 6 have to do anything with the question? Why is the title of your question "prime factor" instead of a more appropriate "prime numbers"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×

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. biggest prime factor
    By robinnbastar in forum C Programming
    Replies: 28
    Last Post: 08-13-2012, 09:36 AM
  2. Prime factor
    By alperen1994 in forum C Programming
    Replies: 6
    Last Post: 03-28-2009, 01:31 PM
  3. last prime factor
    By frango9000 in forum C Programming
    Replies: 7
    Last Post: 07-27-2006, 12:42 PM
  4. Prime factor
    By caroundw5h in forum C Programming
    Replies: 6
    Last Post: 01-13-2004, 03:39 PM
  5. Prime Factor Fxn
    By alpha in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2003, 10:44 AM

Tags for this Thread