Problem Statement
You will be given two positive
Let C be the product of all integers between A and B, inclusive.
The number C has a unique representation of the form C = D * 10^E, where D and E are non-negative integers and the last digit of D is non-zero.
Write a method that will return the value of C formatted as a
Definition
- Class:
- PrettyPrintingProduct
- Method:
- prettyPrint
- Parameters:
- int, int
- Returns:
- String
- Method signature:
- String prettyPrint(int A, int B)
- (be sure your method is public)
Notes
- The purpose of the last constraint is to disallow inputs where precision problems could arise.
Constraints
- A will be between 1 and 1,000,000, inclusive.
- B will be between A and 1,000,000, inclusive.
- If C has more than 10 digits, then the sixth most significant digit of C will be neither 0 nor 9.
Examples
1
10
Returns: "36288 * 10^2"
1 * 2 * ... * 10 = 3628800 = 36288 * 10^2
7
7
Returns: "7 * 10^0"
The product of all numbers between 7 and 7, inclusive, is obviously 7.
211
214
Returns: "2038974024 * 10^0"
For this input D has 10 digits.
411
414
Returns: "28952...24024 * 10^0"
For this input D has 11 digits. Note that we output three dots even if just one digit is missing in the output.
412
415
Returns: "2923450236 * 10^1"
The actual value of C is larger than in the previous example. However, C ends in a zero and therefore D only has 10 digits.
47
4700
Returns: "14806...28928 * 10^1163"
311
314
Returns: "9536499024 * 10^0"
312
315
Returns: "965915496 * 10^1"
1
100000
Returns: "28242...62496 * 10^24999"
1
1000000
Returns: "82639...12544 * 10^249998"
1000000
1000000
Returns: "1 * 10^6"
1
19
Returns: "12164...08832 * 10^3"
Note that the last five digits of D can start with a zero.
8
25
Returns: "30776...34496 * 10^5"
13
25
Returns: "32382...26624 * 10^4"
427784
744439
Returns: "11778...95584 * 10^79163"
448441
732252
Returns: "17954...99328 * 10^70953"
485137
592122
Returns: "15864...30656 * 10^26743"
453285
495368
Returns: "11029...67648 * 10^10519"
826677
991147
Returns: "22456...83328 * 10^41117"
82608
853848
Returns: "16549...75872 * 10^192808"
398036
825775
Returns: "74617...85408 * 10^106935"
551677
622039
Returns: "92473...10944 * 10^17589"
440532
777613
Returns: "90688...26912 * 10^84268"
124812
480191
Returns: "15181...62336 * 10^88846"
65043
286828
Returns: "63366...36224 * 10^55445"
803711
967485
Returns: "11565...14528 * 10^40942"
465688
774960
Returns: "48468...87488 * 10^77316"
44952
779461
Returns: "43655...84352 * 10^183626"
76
89
Returns: "66539...96032 * 10^2"
42
99
Returns: "27898...16032 * 10^13"
78
83
Returns: "27176...94656 * 10^1"
43
97
Returns: "68464...65248 * 10^13"
2
16
Returns: "20922...89888 * 10^3"
99
99
Returns: "99 * 10^0"
69
70
Returns: "483 * 10^1"
24
87
Returns: "81531...66816 * 10^16"
54
81
Returns: "13560...60384 * 10^7"
75
88
Returns: "56072...40416 * 10^4"
74
81
Returns: "12968...03136 * 10^3"
94
97
Returns: "8315616 * 10^1"
27
88
Returns: "45992...60768 * 10^14"
72
99
Returns: "10973...98688 * 10^6"
23
69
Returns: "15224...43968 * 10^11"
62
92
Returns: "24505...32544 * 10^7"
77
78
Returns: "6006 * 10^0"
1
97
Returns: "96192...83232 * 10^22"
82
97
Returns: "16593...05984 * 10^3"
936
917877
Returns: "47132...03616 * 10^229233"
4896
915147
Returns: "71131...58528 * 10^227561"
7392
916397
Returns: "56253...80128 * 10^227250"
5805
945637
Returns: "19689...37984 * 10^234958"
6925
984811
Returns: "23442...49344 * 10^244471"
8542
935433
Returns: "17118...46304 * 10^231721"
5028
999058
Returns: "37894...01792 * 10^248504"
1442
974923
Returns: "67157...09184 * 10^243367"
2359
916372
Returns: "18587...28544 * 10^228502"
9714
909676
Returns: "12844...57056 * 10^224991"
2
1000000
Returns: "82639...12544 * 10^249998"
2
999999
Returns: "82639...12544 * 10^249992"
1
999999
Returns: "82639...12544 * 10^249992"
4
1000000
Returns: "13773...35424 * 10^249998"
1
999935
Returns: "82811...39936 * 10^249978"
2851
999998
Returns: "16675...45312 * 10^249282"
3
999999
Returns: "41319...06272 * 10^249992"