From a discussion on a stack about the programing, I got the following mathematical Conjectures:
Conjectures:
Let n,m be positive integer, $S(n)$ and $CountPosbit(m)$ be as follows.
- $S(n):=\sum_{i=1}^{n} 2^{(i-1)}$
- $CountPosbit(m):=$Number of positive bits when m is converted to binary.
Then, the following holds;
- (1)$CountPosbit(S(n))=n$ for all positive integer, $n$,
- (2)For all positive integer, $m$, following holds;
$CountPosbit(m)=n$ ⇒ $m \ge S(n)$
The following example is to clarify the definition of the $CountPosbit (m)$;
- If $m=10$ in the decimal notation, then
the binary notation of m is 1010 therefore,
$CountPosbit(10)=2$ - If $m=15$ in the decimal notation. then
the binary notation of m is 1111 therefore,
$CountPosbit(15)=4$
For the more detail of the definition of $CountPosbit$ function, refer to the Excel VBA function in Box2 below.
My questions are as follows:
My questions:
- (Q1)Are the above conjectures (1) and (2) correct?
- (Q2)If these are correct, please prove them.
The results of trying with the Excel VBA functions of Box 1 and 2 below are as follows. As far as I tried, no counterexample was found. The worksheet can be downloaded from here.
Box1: Excel VBA function for calculating S (n)
Function S_n(n)
S_n = 0
For i = 1 To n
S_n = S_n + (2 ^ (i-1))
Next i
End Function
Box2: Excel VBA function for CountPosbit(m)
Function CountPosbit(m)
'Substituting a decimal number, this function counts the number of positive bits when the decimal number is converted to a binary number.
tmp = Convert10to2(m)
tot = Len(tmp)
cnt = 0
For i = 1 To tot
If Mid(tmp, tot - i + 1, 1) = 1 Then cnt = cnt + 1
Next i
CountPosbit = cnt
End Function
Function Convert10to2(Value) As String
'This function is for converting decimal numbers to binary numbers.
'This function was quoted from the following website.
'https://www.umayadia.com/main/Samples/Sample055Convert10and2.htm
Dim lngBit As Long
Dim strData As String
Do Until (Value < 2 ^ lngBit)
If (Value And 2 ^ lngBit) <> 0 Then
strData = "1" & strData
Else
strData = "0" & strData
End If
lngBit = lngBit + 1
Loop
Convert10to2 = strData
End Function