i have 2 question that i need help to solve

1. write an algorithm that writes the binary form of a decimal number n

2. if d divides both n and m the d divides their sum and d divides their difference

Printable View

- December 14th 2007, 03:22 AMmonkyshinesneed help !!
i have 2 question that i need help to solve

1. write an algorithm that writes the binary form of a decimal number n

2. if d divides both n and m the d divides their sum and d divides their difference - December 14th 2007, 05:40 AMSoroban
Hello, monkyshines!

Quote:

- December 14th 2007, 06:11 AMSoroban
Hello, monkyshines!

Quote:

1. Write an algorithm that writes the binary form of a decimal number

There is a procedure for this, based on the Euclidean Algorithm.

Example: Convert 87 to binary.

[1] Divide by 2, note the remainder.

. . .

[2] Divide the*quotient*by 2, note the remainder.

. . .

[3] Repeat step [2] until a zero quotient is reached.

. . .

[4] Now read**up**the remainders.

Therefore: .

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

A silly but true story . . .

Years ago, I gave this exact problem on an exam.

One of my top students (with a quirky sense of humor) wrote

. . "Hi-yo, Silver!" next to his (correct) answer.

Of course, when I handed the papers back, I asked him about it.

He said, "Did you*read*the number?"

Puzzled, I mentally thought: "One-zero-one-zero-one-one-one."

OMG ... It's the opening of*The William Tell Overture !*

(I said he was quirky, didn't I?)