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

Home > Numbers > Sequences
Brazilian numbers (Posted on 2017-07-15) Difficulty: 3 of 5
Definition: "Brazilian" numbers ("les nombres brésiliens" in French)are numbers n such that exists a natural number k with 1<k< (n-1) such that the representation of n in base k has all equal digits.

1.Prove that all even numbers above 6 are Brazilian numbers.
2. How many odd Brazilian numbers are there below 100?

See The Solution Submitted by Ady TZIDON    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Program had a bug -- fixed it | Comment 3 of 4 |
Numbers that are in fact Brazilian have their appropriate base and the representation in that base listed.

The bug had been not allowing enough characters to cover bases so that 83 in base 42 looked like a 1, as null characters were appended during the base conversion process, so extra Brazilians were found, such as 83, that were not Brazilian in fact.

4
5
6
7 2   111
8 3   22
9
10 4   22
11
12 5   22
13 3   111
14 6   22
15 2   1111
16 7   22
17
18 5   33
19
20 9   22
21 4   111
22 10   22
23
24 5   44
25
26 3   222
27 8   33
28 6   44
29
30 9   33
31 2   11111
32 7   44
33 10   33
34 16   22
35 6   55
36 8   44
37
38 18   22
39 12   33
40 3   1111
41
42 4   222
43 6   111
44 10   44
45 8   55
46 22   22
47
48 7   66
49
50 9   55
51 16   33
52 12   44
53
54 8   66
55 10   55
56 13   44
57 7   111
58 28   22
59
60 9   66
61
62 5   222
63 2   111111
64 15   44
65 12   55
66 10   66
67
68 16   44
69 22   33
70 9   77
71
72 11   66
73 8   111
74 36   22
75 14   55
76 18   44
77 10   77
78 12   66
79
80 3   2222
81 26   33
82 40   22
83
84 11   77
85 4   1111
86 6   222
87 28   33
88 10   88
89
90 14   66
91 9   111
92 22   44
93 5   333
94 46   22
95 18   55
96 11   88
97
98 13   77
99 10   99

27 done

DefDbl A-Z
Dim crlf$, nlist$, nptr, closest, closelist$, lst$, stack(11), stacklvl
Dim frmla$(1 To 50), leadzeros
' pid=10902

Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
  
 For n = 4 To 99
   found = 0
   For k = 2 To n - 2
     nb$ = base$(n, k)
     match = 1
     For i = 2 To Len(nb)
       If Mid(nb, i, 1) <> Left(nb, 1) Then match = 0: Exit For
     Next
     If match Then found = 1: Exit For
   Next
   If found Then
     Text1.Text = Text1.Text & n & Str(k) & "   " & nb & crlf
     If n Mod 2 = 1 Then ct = ct + 1
    Else
      Text1.Text = Text1.Text & n & crlf
   End If
 Next
 


 
 Text1.Text = Text1.Text & crlf & ct & " done"
  
End Sub

Function base$(n, b)
  v$ = ""
  n2 = n
  Do
    d = n2 Mod b
    n2 = n2 \ b
    v$ = Mid("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", d + 1, 1) + v$
  Loop Until n2 = 0
  base$ = v$
End Function


  Posted by Charlie on 2017-07-15 12:36:30
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (22)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information