flat assembler
Message board for the users of flat assembler.

 Index > Heap > Numerical oddities Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 24, 25, 26  Next
Author
windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Lol, are there others like that?
06 Oct 2009, 19:59
edfed

Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
i've found it accidentally, when converting the spare bytes from my current boot code in base 10.
[--------------]
1d = 1h
06 Oct 2009, 20:03
windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
I learned a little Python(EWWWWW, worst language EVER) over the last few days so I could modify an exporter for Blender. With that knowledge I threw a script together to get this. Should be all the ones from 1 though a million.

0d = 0h
1d = 1h
2d = 2h
3d = 3h
4d = 4h
5d = 5h
6d = 6h
7d = 7h
8d = 8h
9d = 9h
53d = 35h
371d = 173h
5141d = 1415h
99481d = 18499h
8520280d = 820258h

EDIT: WOW! Just finished doing 1 through 100 million. Guess what....NOTHING NEW!

Here's the Python(Ewwwww, worst language EVER) script in case anyone wants to know it:
Code:
```a = 1000000
num=0
while a:
val=int(str(num),16)
m=list(str(val))
m.reverse()
numString=''.join(m)
val2=int(numString)
if num == val2:
print "%id = %ih" % (val,val2)
num+=1
a-=1
```

Just replace the number in "a = 1000000" with whatever you want to test up to.

I need some way to clear my memory of this horrid language. Just look at it! I'd rather sit and stare at thousands of lines of assembly than look at 100 lines of Python.

_________________
----> * <---- My star, won HERE
06 Oct 2009, 20:28
Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
WTF you're joking right? I mean, it looks kinda C-ish so it has good syntax. It looks like a nice language.

_________________
Previously known as The_Grey_Beast
06 Oct 2009, 23:05
windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Hey, I'm someone who codes exclusively in ASM, brainfuck, and Befunge ......I don't like anything "C-ish".

_________________
----> * <---- My star, won HERE
06 Oct 2009, 23:42
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17450
revolution
Either:

a) Show a decimal repdigit number evenly divisible (i.e. no remainder) by 16

or

b) prove there are no decimal repdigits divisible by 16
07 Oct 2009, 00:00
windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
A number is divisible by 16 if its last four numbers are. This follows with the discussion we had many pages back about divisibility. So, to test this I just need to test every number 1-1111, 2-2222, 3-3333, etc. for divisibility by 16.

I wrote up this little python script to do so:
Code:
```import math

a=9
b=1
while a:
c=4
while c:
d=int(math.pow(10,c)-1)
d/=9
d*=b
print d
if d % 16 == 0:
print "\n%s is divisible by 16\n" % d
c-=1
b+=1
a-=1
```

It never prints the "blah is divisible by 16" line. It just outputs all the numbers it tested:
Code:
```1111
111
11
1
2222
222
22
2
......
```

If any of these WERE divisible by 16, it would have printed that out.

I know this isn't a very mathematical approach, but it should be just as good at proving it.

_________________
----> * <---- My star, won HERE
07 Oct 2009, 00:41
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17450
revolution
I should deduct points for using HLL programs to do brute force testing like that!

Hmm, actually no, perhaps better would be for me to make a new problem that cannot be solved by brute force. Let me think about it.
07 Oct 2009, 01:22
windwakr

Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Ya, I don't know what came over me. It's just so easy to use. I've been dragged into the dark side.
07 Oct 2009, 01:24
ass0

Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
same as above but in javascript:
Code:
```<html>
<title>
hex
</title>
<body>
<pre>
<h3>
<script>
var a = 9;
var b = 1;

while(a){
var c = 4;
while(c){
var d = ((Math.pow(10, c)-1)/9)*b;
var e = d+"\n";
if((d%16) == 0){
e = d+"is divisible by 16\n";
}
document.write(e);
c--;
}
a--, b++;
}
</script>
</h3>
</pre>
</body>
</html>
```
So you don't need any other thing that your own browser, just copy/paste in somefile.html and run it.
07 Oct 2009, 01:28
Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
windwakr wrote:
Hey, I'm someone who codes exclusively in ASM, brainfuck, and Befunge ......I don't like anything "C-ish".
To me C is a very middle-level language, procedural, and one of the few HLLs similar to asm (not overly abstracted).

There's even C-- if you want to go low-level (use registers in a C-ish language)

_________________
Previously known as The_Grey_Beast
07 Oct 2009, 14:16
Pinecone_

Joined: 28 Apr 2008
Posts: 180
Pinecone_
since we're translating that code, how about a befunge version?
Code:
```>4:080pv
\,:"10"<_v#:-1p08+*+55g08-
>:#,_\$  v>80g82*%#v_0"61 yb elbisivid si "
-:55+,:|>\$# 1#   #<
v      >\$\$41g1+:":"-!#@ #~_41p    ```

(thought it'd be good practice, and it was, suprisingly it took a fair while and a few different approaches to get that working and tested)

Last edited by Pinecone_ on 10 Oct 2009, 09:44; edited 1 time in total
09 Oct 2009, 14:33
kohlrak

Joined: 21 Jul 2006
Posts: 1421
kohlrak
Powers of 2 divisibility rules...

2 if rightmost is...
4 if righmost 2 are...
8 if rightmost 3 are...
16 if rightmost 4 are...

Could i take a guess that continues? That'd be a numerical oddity in itself (or am i restating a fact a few pages ago?).
10 Oct 2009, 07:26
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17450
revolution
Choose two arbitrary numbers, a and b
Code:
```             a + b = c
(a + b)(a - b) = c(a - b)
a^2 - b^2 = ca - cb
a^2 - ca = b^2 - cb
a^2 - ca + (c^2)/4 = b^2 - cb + (c^2)/4
(a - c/2)^2 = (b - c/2)^2
a - c/2 = b - c/2
a = b    ```
All numbers are the same.
24 Mar 2010, 09:53
MHajduk

Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
revolution wrote:
Choose two arbitrary numbers, a and b
Code:
```             a + b = c
(a + b)(a - b) = c(a - b)
a^2 - b^2 = ca - cb
a^2 - ca = b^2 - cb
a^2 - ca + (c^2)/4 = b^2 - cb + (c^2)/4
(a - c/2)^2 = (b - c/2)^2
a - c/2 = b - c/2
a = b    ```
All numbers are the same.
There should be
Code:
`|a - c/2| = |b - c/2|    `
Code:
`a - c/2 = b - c/2    `

because always
Code:
`sqrt(x^2) = |x|    `
where |x| means absolute value of x.
24 Mar 2010, 10:08
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17450
revolution
MHajduk: Sorry, not the answer. There is something missing, but it is not that.
24 Mar 2010, 10:16
MHajduk

Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
revolution wrote:
MHajduk: Sorry, not the answer. There is something missing, but it is not that.
Are you kidding revolution, right?
24 Mar 2010, 10:19
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17450
revolution
No, I was not kidding. Hehe, your "solution" leads to the same incorrect result as I posted.
24 Mar 2010, 10:38
MHajduk

Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
revolution my and yours results aren't the same!!! Seems, that you don't know maths.

Now, let's see what mean a - c/2 and b - c/2.

Because c/2 = (a+b)/2 we have

a - c/2 = a - (a + b)/2 = (2a - (a + b))/2 = (2a - a - b)/2 = (a - b)/2

Similarly

b - c/2 = b - (a + b)/2 = (2b - (a + b))/2 = (2b - a - b)/2 = (b - a)/2

So

|a - c/2| = |b - c/2|

could be transformed into

|(a - b)/2| = |(b - a)/2|

What gives us

|a - b| = |b - a|

what is always true because

|a - b| = |-(b-a)| = |b - a|

|a - b| = |b - a|

What, of course, doesn't mean that a = b!

Last edited by MHajduk on 24 Mar 2010, 11:11; edited 4 times in total
24 Mar 2010, 10:49
kohlrak

Joined: 21 Jul 2006
Posts: 1421
kohlrak
When all else fails, put in actual numbers... If the case is ever false, all it takes is one situation. Arguing with alphabet soup will get you nowhere.
24 Mar 2010, 10:57
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 24, 25, 26  Next

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum