Dmitri Makovetskiy

Ranch Hand

Posts: 128

posted 7 years ago

my task is to use a loop,, i need the loop to go till 77777

the problem is that the numbers need to be octagon type.. 1-8 instead of 1-10. i have no idea how to make that conversion. i created 2 loops...

i tried to come up with a code for 2 hours. but no luck

it should count the numbers like that:

12345678 then add another series to this one..

12345678

so it would be 1+1 2+2 3+3.....

until it reaches 77777

the problem is that the numbers need to be octagon type.. 1-8 instead of 1-10. i have no idea how to make that conversion. i created 2 loops...

i tried to come up with a code for 2 hours. but no luck

it should count the numbers like that:

12345678 then add another series to this one..

12345678

so it would be 1+1 2+2 3+3.....

until it reaches 77777

posted 7 years ago

Change 77777 into 077777 - that makes it the octal representation of 32767. The loop guard would be "while (count < 0100000)". Instead of 8 you can use 010. You see, by adding a 0 before the number the compiler uses base-8*, just like adding 0x at the starts makes it base-16* or HEX. 010 is nothing more than 1*8^1 + 0*8^0, and 077777 is 7*8^4 + 7*8^3 + 7*8^2 + 7*8^1 + 7*8^0

For the purists: base-10, since everything is base-10

For those that don't get it - read it as base-one-zero, not base-ten.

For the purists: base-10, since everything is base-10

For those that don't get it - read it as base-one-zero, not base-ten.

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6

How To Ask Questions How To Answer Questions

Dmitri Makovetskiy

Ranch Hand

Posts: 128

posted 7 years ago

i did what you told me to do.. it gives me an octal representation, but i should get a decimal or some other presentation that would make the numbers reach 77777.

the instructions to do this exercise are so tricky.

i think, that the persentation should be something like that...

1

2

3

4

5

6

7

8

11

12

13

14

15

16

17

18

20

21

22

23

24

..

..

..

..

..

77775

77776

77777

i am not 100% sure.

but the instruction that i got was to make the application display all the numbers from 0 to 77777 (octal)

i think you are close to the answer, because that is how you get an octal number (8^1 2*8^2....)

but in practice how do i feed that formula into a loop, do i need one or two loops?

i need to make it so that it would add a series of 1-8 with another 1-8 until you reach 77777.

those were the instructions, to display octal numbers from 0-77777

no idea how it is done, but it must have a loop and a few basic operators

usually i use basic operators and i am learning how to use a loop. but i am not sure how to use 2 loops, cause i think in this problem i need to use 2 loops

Rob Prime wrote:Change 77777 into 077777 - that makes it the octal representation of 32767. The loop guard would be "while (count < 0100000)". Instead of 8 you can use 010. You see, by adding a 0 before the number the compiler uses base-8*, just like adding 0x at the starts makes it base-16* or HEX. 010 is nothing more than 1*8^1 + 0*8^0, and 077777 is 7*8^4 + 7*8^3 + 7*8^2 + 7*8^1 + 7*8^0

For the purists: base-10, since everything is base-10

For those that don't get it - read it as base-one-zero, not base-ten.

i did what you told me to do.. it gives me an octal representation, but i should get a decimal or some other presentation that would make the numbers reach 77777.

the instructions to do this exercise are so tricky.

i think, that the persentation should be something like that...

1

2

3

4

5

6

7

8

11

12

13

14

15

16

17

18

20

21

22

23

24

..

..

..

..

..

77775

77776

77777

i am not 100% sure.

but the instruction that i got was to make the application display all the numbers from 0 to 77777 (octal)

i think you are close to the answer, because that is how you get an octal number (8^1 2*8^2....)

but in practice how do i feed that formula into a loop, do i need one or two loops?

i need to make it so that it would add a series of 1-8 with another 1-8 until you reach 77777.

those were the instructions, to display octal numbers from 0-77777

no idea how it is done, but it must have a loop and a few basic operators

usually i use basic operators and i am learning how to use a loop. but i am not sure how to use 2 loops, cause i think in this problem i need to use 2 loops

Joanne Neal

Rancher

Posts: 3742

16

Dmitri Makovetskiy

Ranch Hand

Posts: 128

Dmitri Makovetskiy

Ranch Hand

Posts: 128

posted 7 years ago

I have made a copy of this thread and moved it to the Ranch Office forum. Any discussion of cross-posting should be take up there.

Anyone who reads this thread should know the OP has also asked this question on at least one other forum, and may have gotten his answer there.

Anyone who reads this thread should know the OP has also asked this question on at least one other forum, and may have gotten his answer there.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Consider Paul's rocket mass heater. |