![]() |
![]() |
#1 |
Jun 2003
110001010112 Posts |
![]()
Given a natural number N is there a fast way to test if the number is of the form k*b^n+-c where b^n contributes to 99% size of N; c<m*n where m is small.
Brute force could be one way:- calculating N%b, N%b^2 ... and checking if they are all same. Anything faster? Would taking log of N help? |
![]() |
![]() |
![]() |
#2 | |
Jun 2003
10010111010102 Posts |
![]() Quote:
If b & c can be reasonably limited (say both < 1e9), you can use sieving techniques to quickly figure out valid (b,c) combinations that can potentially equal N. |
|
![]() |
![]() |
![]() |
#3 | |
Jun 2003
1,579 Posts |
![]() Quote:
A faster way might be to to :- calculate max_n = log(N)/log(2) then for all n from 2 to max_n you calculate corresponding b value (use log to solve) int(N^(1/n))=b Since this is approximate we want to check b-1, b and b+1 Then sieve over these values to see if there is a solution. This would still be under brute force. Anything faster than this? |
|
![]() |
![]() |
![]() |
#4 | |
Jun 2003
10010111010102 Posts |
![]() Quote:
I think we can slightly optimize the previous b-based approach to only look at prime b's. |
|
![]() |
![]() |
![]() |
#5 | |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
3×1,999 Posts |
![]() Quote:
The first number to match the criteria is 100 = 1*99^1+1 Then 200 = 1*198^1+2 Then x*100 = 1*(99x)^1+x etc. So all you have to do is check that the number is divisible by 100. |
|
![]() |
![]() |
![]() |
#6 |
Jun 2003
1,579 Posts |
![]() |
![]() |
![]() |
![]() |
#7 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
3·1,999 Posts |
![]() |
![]() |
![]() |
![]() |
#8 |
Jun 2003
2·32·269 Posts |
![]()
Sure, b can be composite. But a composite b must also pass a prime b check as a necessary condition.
For example, consider N=7*6^100+11. It will pass the b=2 check. Code:
? N=7*6^100+11; ? N%(2^64) %2 = 11 ? N%(2^65) %3 = 11 Code:
? N%(3^64) %4 = 11 ? N%(3^65) %5 = 11 So we can limit ourselves to prime bases, as a first pass. In second pass, we subtract the potential c from N (i.e. N - N%(b^k) ) and then trial divide it to see if it factorises into small factors. If so, we get the actual representation as well. |
![]() |
![]() |
![]() |
#9 |
Jun 2003
2×32×269 Posts |
![]() |
![]() |
![]() |
![]() |
#10 | |
Jun 2003
110001010112 Posts |
![]() Quote:
For small k values and large n values only 1-2 b values will be possible. For small n a large number of b values will be possible. I am more interested in the first case. To refine the question I am looking for k<m*n c<m*n n*m>b with m small |
|
![]() |
![]() |
![]() |
#11 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
3×1,999 Posts |
![]()
Okay. But it still doesn't meet the criterion 99%.
log(6¹⁰⁰)/log(7×6¹⁰⁰+11) = 98.92...% Indeed for any integer N I can't see how you ever get 99%. The only way would be something like e×e⁹⁹+0 = 99%. So k=e, b=e, n=99, c=0. And other multiples of those values. Last fiddled with by retina on 2020-08-02 at 06:38 |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
More Power!!!! | petrw1 | Teams | 10 | 2019-10-15 17:36 |
TDP as power used? | CRGreathouse | Hardware | 9 | 2016-02-06 18:46 |
Power 2 | JohnFullspeed | Miscellaneous Math | 45 | 2011-07-10 20:13 |
testing, if a number is a power | bitblit | Math | 8 | 2009-04-24 02:48 |
IBM Power 6 | Unregistered | Information & Answers | 7 | 2008-08-30 14:36 |