I am assuming you mean positive integer in decimal notation.
Here is an algorithm that lists the binary representation backwards, that is
from right to left, least significant digit first.
N is the number decimal number
While N > 0
print N rem 2 // output the remainder
N = N/2 // replace N by n divided by 2
end loop
Example: trace for n = 101
n output
101
50 1
25 0
12 1
6 0
3 0
1 1 -- Last one had 0; 3%2 is 1
0 1
Output would be 1010011 ---- from left to right would be 1100101
Check: 64 + 32 + 0 + 0 + 4 + 1 = 101.
Chat with our AI personalities
A root-finding algorithm is a numerical method, or algorithm, for finding a value. Finding a root of f(x) − g(x) = 0 is the same as solving the equation f(x) = g(x).
By finding a pattern the first time you solve a problem, then applying this pattern (algorithm) to solve similar problems.
Find the radiusMultiply pi by the square of the radius.
Finding the nearest decimal
A factor tree is a representation of the process of finding the prime factorization of a given number.