x^2 + S(x)*x - n=0 where n can be till 10^8 interger . and s(x) is the sum of the digits of the x integer. we have to print the value of x for which this equation holds otherwise print -1. my answer is taking too much time with brute force. can anyone give any hint ?

## Recommended Answers

Jump to PostHmm how do you brute force it currently? Some optimizations (but it's still brute forcing) would be to:

don't count the amount of digits per attempted number (or maybe not at all) instead start at i=10, j = 1 where you multiply i by 10 everytime your number hits i …

## All 3 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.