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

.model flat,stdcall
option casemap:none
include C:\masm32\include\
include C:\masm32\include\
includelib C:\masm32\lib\kernel32.lib
PrimeDiv proto :DWORD,:DWORD


invoke GlobalAlloc,GMEM_FIXED,10000h
mov edi,eax
invoke PrimeDiv,2111435,edi
invoke GlobalFree,edi
call ExitProcess

PrimeDiv proc Num,Table
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
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
inc dword ptr [esi+4]
cmp eax,1
je @end
mov Num,eax
@sqrt: fild Num
fistp sqrt
cmp sqrt,ebx
jnc @divide
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.
Posted on 2001-12-24 08:53:38 by The Svin
Svin.....what exactly is the Gauss Main Arithmetic Theory. In english that is.

Posted on 2002-08-22 11:24:01 by IwasTitan
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
Posted on 2002-08-22 17:52:27 by iblis
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.
Posted on 2002-08-22 19:08:48 by Tomasz Grysztar
Ob'yasnite, pozhalusta. :)
Posted on 2002-08-23 12:37:39 by comrade
try to prove Goldbach theory:grin:

but i doubt if this can called a real prove


Posted on 2002-08-23 15:16:04 by eko
try to prove Goldbach theory

Whats the Goldbach theory?

Posted on 2002-08-23 16:13:27 by IwasTitan
that every even integer greater than 2 can be represented as the sum of two primes

that is goldbach theory


Posted on 2002-08-23 16:18:49 by eko