Problem Statement
Find the smallest positive integer value of n such that a*(n^k) < k^n, where a and k are given integral values and ^ denotes exponentiation.
Solving this problem algebraically involves using the overly complicated Lambert W function. Instead you are to solve the problem by creating a class HardIneq with a method biggestVal which, given a and k, returns the smallest positive integer value of n such that a*(n^k) < k^n.
Definition
- Class:
- HardIneq
- Method:
- biggestVal
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int biggestVal(int a, int k)
- (be sure your method is public)
Notes
- Remember that log(x^y) = y * log(x) and that log(x*y) = log(x) + log(y)
Constraints
- a will be between 1 and 10000, inclusive
- k will be between 2 and 1000, inclusive
Examples
10
5
Returns: 8
if n = 1, we have a*(n^k) = 10*(1^5) = 10, and k^n = 5^1 = 5. 10 is not less than 5. n=2: 10*2^5 is not less than 5^2 n=2: 10*3^5 is not less than 5^3 and so on. Not until we get to n = 8, and have 10*8^5 = 327680, and 5^8 = 390625 is the inequality satisfied.
1
2
Returns: 1
1*(1^2) is less than 2^1, so we return 1.
2
20
Returns: 1
2000
200
Returns: 202
1000
100
Returns: 102
503
33
Returns: 36
31
23
Returns: 25
100
99
Returns: 101
657
12
Returns: 17
99
100
Returns: 1
861
2
Returns: 19
1634
242
Returns: 244
3147
434
Returns: 436
463
777
Returns: 1
4210
191
Returns: 193
1387
7
Returns: 13
2740
73
Returns: 76
6248
797
Returns: 799
4913
95
Returns: 98
4046
448
Returns: 450
265
651
Returns: 1
6103
582
Returns: 584
2208
649
Returns: 651
6063
918
Returns: 920
6661
714
Returns: 716
8667
459
Returns: 461
5040
509
Returns: 511
1562
541
Returns: 543
828
999
Returns: 1
2541
112
Returns: 115
4765
807
Returns: 809
561
517
Returns: 519
2245
613
Returns: 615
2626
84
Returns: 87
7991
962
Returns: 964
230
791
Returns: 1
7248
708
Returns: 710
8402
344
Returns: 346
9813
755
Returns: 757
7625
58
Returns: 61
3061
752
Returns: 754
3877
52
Returns: 55
2789
851
Returns: 853
4907
379
Returns: 381
6184
678
Returns: 680
1439
904
Returns: 906
9515
234
Returns: 237
505
912
Returns: 1
4238
506
Returns: 508
4320
680
Returns: 682
9142
214
Returns: 217
2200
492
Returns: 494
2866
237
Returns: 239
4924
866
Returns: 868
688
975
Returns: 1
613
91
Returns: 93
1801
94
Returns: 97
8722
508
Returns: 510
8507
841
Returns: 843
4072
390
Returns: 392
6690
424
Returns: 426
27
3
Returns: 10
Note that 27*9^3 is equal to 3^9.
729
6
Returns: 13
10000
1000
Returns: 1002
2000
200
Returns: 202
27
3
Returns: 10
9999
1000
Returns: 1002