All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Persistence I (Posted on 2017-12-24)
Let's define persistence of an integer number p(N) as the number of times one has to multiply said number's digits before reaching a single digit.
Examples: 48==>32==>6, so p(48)=2;
23568643407==>0 , so p(23568643407)=1

a. (easy). Comment on the value of p(N!) for a non-negative N.
b.(harder) What can be said of the values of p(N) in bases 2 or 3.
c. (hardest) How many 3-digit integers with p(N)=3 are there?

Try to solve analytically.

 See The Solution Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 some analysis; some computation-- solution except for b) in base 3. Comment 2 of 2 |
Part a:

The persistence of any of the factorials is 1.

For 1! through 4! the product happens to be a single-digit number, and from 5! onward all factorials end in (and therefore include) a zero resulting in a product of zero, which is immmediate, so the persistence is 1:

2  2    2     1
3  6    6     1
4  24    8     1
5  120    0     1
6  720    0     1
7  5040    0     1
8  40320    0     1
9  362880    0     1
10  3628800    0     1
11  39916800    0     1
12  479001600    0     1
13  6227020800    0     1
14  87178291200    0     1
15  1307674368000    0     1
16  20922789888000    0     1
17  355687428096000    0     1

But you might say the persistence of a single digit number is zero, since it's already a single-digit number and no multiplications need be done. In that case p(2!) and p(3!) are both zero.

Part b:

In binary, all digits are either zero or one. The product of a repunit's digits is 1, a single-digit number, and the product of any other binary number's digits is zero, as the only possible digit other than 1 is 0, and zero is also a 1-digit number. So all binary numbers have persistence 1, except if you consider integers 0 and 1 themselves to have persistence zero.

Base 3 is more complicated, prompting a program:

For n = 1 To 100
n1 = n: pn = 0
Do
ctd = 0
Do
d = n1 Mod 3: n1 = n1 \ 3
ctd = ctd + 1
rep(0) = ctd
rep(ctd) = d
Loop Until n1 = 0
pn = pn + 1
n1 = 1
For i = 1 To ctd
n1 = n1 * rep(i)
Next
Loop Until ctd = 1
Text1.Text = Text1.Text & n & "  " & pn & crlf
Next n

Most numbers have persistence 1. There are of course the single-digit numbers 0, 1 and 2 with persistence 0.

But 8 (in decimal) is 22; that leads to representation 11, for four, then 1; that's persistence 2.

17 also has persistence 2, from representations: 221, 11, 1.

Then
23: 212 to 11 to 1
25: 122 to 11 to 1
26: 222 to 22 to 11 to 1 , making p(26), that is p(222 base 3) 3 in decimal.

A question becomes whether the persistence can get higher than 3 for any base-3 representation of a number. I haven't found any going up to 100,000 in base 10.

Part c:

There are 287 3-digit numbers with persistence 3:

139
147
149
155
157
159
166
168
169
174
175
178
179
186
187
188
189
193
194
195
196
197
198
227
229
236
238
239
246
247
248
249
263
264
266
267
272
274
276
279
283
284
288
289
292
293
294
297
298
299
319
326
328
329
333
334
335
336
337
338
343
344
346
347
353
359
362
363
364
367
368
369
373
374
376
382
383
386
388
389
391
392
395
396
398
399
417
419
426
427
428
429
433
434
436
437
443
444
448
449
462
463
466
468
469
471
472
473
478
479
482
484
486
487
488
491
492
494
496
497
499
515
517
519
533
539
551
555
559
571
577
579
591
593
595
597
616
618
619
623
624
626
627
632
633
634
637
638
639
642
643
646
648
649
661
662
664
666
667
669
672
673
676
681
683
684
689
691
693
694
696
698
714
715
718
719
722
724
726
729
733
734
736
741
742
743
748
749
751
757
759
762
763
766
775
779
781
784
791
792
794
795
797
799
816
817
818
819
823
824
828
829
832
833
836
838
839
842
844
846
847
848
861
863
864
869
871
874
881
882
883
884
888
889
891
892
893
896
898
913
914
915
916
917
918
922
923
924
927
928
929
931
932
935
936
938
939
941
942
944
946
947
949
951
953
955
957
961
963
964
966
968
971
972
974
975
977
979
981
982
983
986
988
992
993
994
997

The statistics for 3-digit numbers:

p(N)  count

1    215
2    306
3    287
4     83
5      9

For curiousity's sake, the p(N) = 5 numbers are

679
688
697
769
796
868
886
967
976

DefDbl A-Z
Dim crlf\$, pCt(10)

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

Text1.Text = Text1.Text & "Part a:" & crlf
fact = 1: n = 1
Do
n = n + 1: fact = fact * n
Text1.Text = Text1.Text & n & "  "
If fact > 5E+15 Then Exit Do
pers = 0: prod\$ = LTrim(Str(fact))
Text1.Text = Text1.Text & fact & "    "
Do
p = 1
For i = 1 To Len(prod)
p = p * Val(Mid(prod, i, 1))
Next
prod = LTrim(Str(p))
pers = pers + 1
Text1.Text = Text1.Text & prod & "     "
Loop Until Len(prod) = 1
Text1.Text = Text1.Text & pers & crlf
DoEvents
Loop

Text1.Text = Text1.Text & crlf & "Part c:" & crlf

For n = 100 To 999
pers = 0: prod\$ = LTrim(Str(n))
Do
p = 1
For i = 1 To Len(prod)
p = p * Val(Mid(prod, i, 1))
Next
prod = LTrim(Str(p))
pers = pers + 1
Loop Until Len(prod) = 1
If pers = 3 Then
Text1.Text = Text1.Text & n & crlf
End If
pCt(pers) = pCt(pers) + 1
DoEvents
Next
For i = 0 To 10
Text1.Text = Text1.Text & pCt(i) & crlf
Next

Text1.Text = Text1.Text & crlf & " done"

End Sub

 Posted by Charlie on 2017-12-24 14:13:06

 Search: Search body:
Forums (0)