Help me to find the largest prime factor of an integer.

Discussion in 'C' started by aniknaruto, Jan 31, 2010.

  1. aniknaruto

    aniknaruto New Member

    Joined:
    Jan 24, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    My program didn't work . I couldn't find any mistake . When i compiled it , it showed error in 17 line .What should i do ?
    Here is my code :
    Code:
    #include<stdio.h>
    #include<stdlib.h>
    #include<math.h>
    main()
    {long int a,b,c,d,e,f;   
    d=1; 
    scanf("%ld",&a);
    for(e=a;e>=1;e--)
    {f=a%e;
    if(f==0)
    {
    for(b=1;b<=sqrt(e);b++)
    {c=e%b;
    
    if(c==0)
    {d=d+1;
     
          }
           }
    if(d==2)
    {
    goto AA;}
    }
    
            } 
            }  
    
    AA:
    print("%ld",e);        
    system("pause");  
          }
     
    Last edited by a moderator: Feb 1, 2010
  2. aniknaruto

    aniknaruto New Member

    Joined:
    Jan 24, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    The compiler showed error in 17th line . I used dev-c++ 4.9.9.2 .
     
  3. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    My mind reading skills are a bit off today. Would you be so kind as to tell us what the compiler error was?

    Please format your code for readability and post it using code tags. Type:

    [noparse]
    Code:
    
      int main()
      {
        return 0;
      }
    
    [/noparse]

    to give this:
    Code:
    
      int main()
      {
        return 0;
      }
    
    At a quick glance, it seems that there are more '}' than '{' characters.
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Also please explain your alrogithm and what the variables are for. Using single letter variable names makes the code completely unreadable.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice