Represent number by prime dividers and their power.

Create an array structers of those divides + power

First two dwords are zeros and then dividers+power

Alex, I just added the formatting so the source was easier to read.

Create an array structers of those divides + power

First two dwords are zeros and then dividers+power

```
```

.586

.model flat,stdcall

option casemap:none

include C:\masm32\include\windows.inc

include C:\masm32\include\kernel32.inc

includelib C:\masm32\lib\kernel32.lib

PrimeDiv proto :DWORD,:DWORD

.code

start:

invoke GlobalAlloc,GMEM_FIXED,10000h

mov edi,eax

invoke PrimeDiv,2111435,edi

invoke GlobalFree,edi

call ExitProcess

PrimeDiv proc Num,Table

LOCAL sqrt:DWORD

mov esi,Table

cmp Num,1

mov eax,0

jbe @end

test Num,1

mov eax,Num

mov dword ptr [esi],0

jne @init

bsf ecx,eax

add esi,8

shl eax,cl

mov [esi+4],ecx

mov Num,eax

mov dword ptr [esi],2

cmp eax,1

je @end

@init: mov ebx,3

jmp @sqrt

;------------------------------------------

@divide:

xor edx,edx

div ebx

test edx,edx

je @write

add ebx,2

cmp sqrt,ebx

mov eax,Num

jnc @divide

jmp @Prime

@write: cmp [esi],ebx

je @thesame

add esi,8

mov [esi],ebx

mov dword ptr [esi+4],0

@thesame:

inc dword ptr [esi+4]

cmp eax,1

je @end

mov Num,eax

@sqrt: fild Num

fsqrt

fistp sqrt

cmp sqrt,ebx

jnc @divide

@Prime:

add esi,8

mov [esi],eax

mov dword ptr [esi+4],1

mov eax,1

@end: ret

PrimeDiv endp

end start

Alex, I just added the formatting so the source was easier to read.

Svin.....what exactly is the Gauss Main Arithmetic Theory. In english that is.

:alright:

:alright:

I think he means the fundamental theorem of arithmetic.

Any non-prime integer can be expressed as the product of prime numbers, the prime factors. (prime dividers as Svin called it) but is'nt equal to the product of any other prime set. The theorem says that prime numbers are the basic foundation of integers.

e.g. 1050 = 2 x 3 ? 5 x 5 x 7

Any non-prime integer can be expressed as the product of prime numbers, the prime factors. (prime dividers as Svin called it) but is'nt equal to the product of any other prime set. The theorem says that prime numbers are the basic foundation of integers.

e.g. 1050 = 2 x 3 ? 5 x 5 x 7

You don't have to calculate the sqrt, you know you have crossed the sqrt boundary when the quotient is smaller than divisor.

I'm attaching the small module for computation of major number theory functions I have written once, it includes the factorization into prime factors (this is version for fasm, but needs only very little changes to be adapted for other assembler). It was quick and dirty work and was never optimized, because I just needed it for a few calculations. The "numbers" is a small example that uses this library.

I'm attaching the small module for computation of major number theory functions I have written once, it includes the factorization into prime factors (this is version for fasm, but needs only very little changes to be adapted for other assembler). It was quick and dirty work and was never optimized, because I just needed it for a few calculations. The "numbers" is a small example that uses this library.

Ob'yasnite, pozhalusta. :)

try to prove Goldbach theory:grin:

but i doubt if this can called a real prove

bye

eko

but i doubt if this can called a real prove

bye

eko

try to prove Goldbach theory

Whats the Goldbach theory?

:alright:

Whats the Goldbach theory?

:alright:

http://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Goldbach.html

that every even integer greater than 2 can be represented as the sum of two primes

that is goldbach theory

bye

eko