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
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Lol, are there others like that?
Post 06 Oct 2009, 19:59
View user's profile Send private message Reply with quote
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
Post 06 Oct 2009, 20:03
View user's profile Send private message Visit poster's website Reply with quote
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
Post 06 Oct 2009, 20:28
View user's profile Send private message Reply with quote
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
Post 06 Oct 2009, 23:05
View user's profile Send private message Reply with quote
windwakr



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

_________________
----> * <---- My star, won HERE
Post 06 Oct 2009, 23:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
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
Post 07 Oct 2009, 00:00
View user's profile Send private message Visit poster's website Reply with quote
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
Post 07 Oct 2009, 00:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
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.
Post 07 Oct 2009, 01:22
View user's profile Send private message Visit poster's website Reply with quote
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.
Post 07 Oct 2009, 01:24
View user's profile Send private message Reply with quote
ass0



Joined: 31 Dec 2008
Posts: 521
Location: ( . Y . )
ass0
same as above but in javascript:
Code:
<html>
<head>
<title>
hex
</title>
</head>
<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.
Post 07 Oct 2009, 01:28
View user's profile Send private message Reply with quote
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 Very Happy......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) Very Happy

_________________
Previously known as The_Grey_Beast
Post 07 Oct 2009, 14:16
View user's profile Send private message Reply with quote
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
Post 09 Oct 2009, 14:33
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
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?).
Post 10 Oct 2009, 07:26
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
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.
Post 24 Mar 2010, 09:53
View user's profile Send private message Visit poster's website Reply with quote
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|    
instead of
Code:
a - c/2 = b - c/2    
Wink
because always
Code:
sqrt(x^2) = |x|    
where |x| means absolute value of x. Smile
Post 24 Mar 2010, 10:08
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
MHajduk: Sorry, not the answer. There is something missing, but it is not that.
Post 24 Mar 2010, 10:16
View user's profile Send private message Visit poster's website Reply with quote
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?
Post 24 Mar 2010, 10:19
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
No, I was not kidding. Hehe, your "solution" leads to the same incorrect result as I posted.
Post 24 Mar 2010, 10:38
View user's profile Send private message Visit poster's website Reply with quote
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. Wink

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|

Hence the proper answer is
|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
Post 24 Mar 2010, 10:49
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
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.
Post 24 Mar 2010, 10:57
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 24, 25, 26  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.