[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I need to develop an algorithm that takes a number M and finds
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 27
Thread images: 2
I need to develop an algorithm that takes a number M and finds a number that his inverse (inverse numbers: 24-42, also 0s dont count so another example is 24000- 42)summed with him makes M.
Example the number 908 is given, one solution is 256.
M can be as high as 10^100000
>>
in what base?
>>
>>54505585
Take your image's advice and contemplate suicide
>>
>>54505585
Why?
>>
>>54505593
decimal

I just want ideas or whatever
>>
>>54505585
>Example the number 908 is given, one solution is 256.
This doesn't make sense. It sounds like your algorithm is "find N such that M=INVERSE(M)+N" however, INVERSE(908) is 89, and 89 + 256 = 345.
>>
>>54505606
Idea: one of the two numbers must be less than M/2
>>
>>54505627
that was a fault of mine, zeros on the right or left are not considered
>>
>>54505627
find N such that M=INVERSE(N)+N
>>
>>54505635
Why the hell would zeros not be considered if on the right.
>>
>>54505629
that was my first idea also but then i came to the conclusion that you cant treat these numbers like numbers but more like arrays of single numbers because of their size
>>
>>54505649
because then they go left and 0042=42
>>
>>54505649
Wouldn't they not matter in inverse?

Inverse of 0010 is 0100 or 010000 or 01
>>
>>54505664
inversion happens from the first non-zero digit starting from the right
>>
Hint, the difference between a number and its inverse is always a multiple of 9
>>
>>54505706
explain?
>>
>>54505715
321-123=198

198 = 9 * 22
>>
>>54505706
Hint, the difference between a number and its inverse is always a multiple of 9

not the case if you ignore zeroes as OP mentioned
>>
>>54505760
2400-42 = 2358 = 9 * 262
>>
>>54505739
Yes but can this info be used to achieve the desired outcome
>>
>>54505760
zeroes just multiply that difference by ten so it also applies then
>>
File: super_smug.png (22 KB, 217x225) Image search: [Google]
super_smug.png
22 KB, 217x225
What university/college OP?
>>
>>54505774
M - 2*N is divisible by 9
>>
>>54505811
could you imagine dividing numbers of the size 10^1000000
>>
>>54505835
Modular arithmetic for huge numbers trivial
>>
>>54505585
It's pretty easy to prune number based on whether or not the number is odd or even.

Consider the case M = 908 and current N being checked is 43, an odd number.
Its inverse, 34, is an even number, which means you get an odd number from its result.


To save the algorithm some search time, you can skip numbers based on this. If you do it right, you don't even need to perform modulus.
>>
>>54505585
I'd try to help you if you could write a coherent English sentence
Thread replies: 27
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.