You might want to check out Pollard Rho algorithm. On Sat, Aug 27, 2011 at 9:57 PM, Rahul Verma <[email protected]> wrote: > I am trying to submit solution for the SPOJ DIVSUM problem, but it returns > the time limit exceeded. Code submitted by me is below: > > #include <cstdlib> > #include <iostream> > using namespace std; > int proper_divisor(int number); > int main() > { > int test,i,number; > cin>>test; > for(i=0; i<test; i++) > { > cin>>number; > proper_divisor(number); > } > } > int proper_divisor(int number) > { > int i,n=0; > for(i=1; i<number-1; i++) > { > if(number%i==0) > { > n=n+i; > } > } > //cout<<n<<"\n"; > } > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/vld8Fghb1twJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. >
-- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
