×

# Inspiration for Binary and 3

Write a program to accomplish following task.

Your friend Jack enters bits of a binary number (unit bit then two's bit then four's bit then ...). He will terminate by entering a non binary digit (i. e. anything other than 0 and 1). Each time he enters digit, tell him whether number formed so far is divisible by 3 (i.e. $$11_2$$) or not.

Note by Rushi Jogdand
8 months, 3 weeks ago

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$...$$ or $...$ to ensure proper formatting.
2 \times 3 $$2 \times 3$$
2^{34} $$2^{34}$$
a_{i-1} $$a_{i-1}$$
\frac{2}{3} $$\frac{2}{3}$$
\sqrt{2} $$\sqrt{2}$$
\sum_{i=1}^3 $$\sum_{i=1}^3$$
\sin \theta $$\sin \theta$$
\boxed{123} $$\boxed{123}$$

Sort by:

Take the difference between sums of alternate digits. If it is 0 or is divisible by 3, then the number is divisible by 3. I'll let you think, why so?

- 8 months, 1 week ago

Analogus to "divisibility test for $$11_{10}$$", isn't it? Can you solve this one and post your solution.

- 8 months, 1 week ago

The question to which you have linked. Is $B$ fixed? Then, $S$ contains $\le n$ nunbers or did you mean all such $2^n$ numbers?

- 8 months, 1 week ago

The file contains a single (large) binary number = B. The wording is meant to emitate input of digits (hence, unit digit come first, then two's...). The ideas is to put a digit to right of the number, check divisibility, do this till EOF.

- 8 months, 1 week ago