Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Help me to find the largest prime factor of an integer. (http://www.go4expert.com/forums/help-largest-prime-factor-integer-t20828/)

aniknaruto 1Feb2010 02:08

Help me to find the largest prime factor of an integer.
 
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"); 
      }


aniknaruto 1Feb2010 02:24

Re: Help me to find the largest prime factor of an integer.
 
The compiler showed error in 17th line . I used dev-c++ 4.9.9.2 .

Gene Poole 1Feb2010 04:19

Re: Help me to find the largest prime factor of an integer.
 
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:

[code]

int main()
{
return 0;
}
[/code]

to give this:
Code:


  int main()
  {
    return 0;
  }

At a quick glance, it seems that there are more '}' than '{' characters.

xpi0t0s 1Feb2010 22:10

Re: Help me to find the largest prime factor of an integer.
 
Also please explain your alrogithm and what the variables are for. Using single letter variable names makes the code completely unreadable.


All times are GMT +5.5. The time now is 23:32.