This snippet can find an fator of
4567891315649817020467878943221130691322456498497
factor 6,840,899
i have tryed to find an factor of 54468798756132164897 but i think it is an prime number. I have check to 50,000,000.
This snippet can only check for an factor from 1 to 99,999,999. I'm still working out how to find larger factors.
SET EMULATION off : sync rate 0 : sync on : hide mouse
cls 0
Number$ = "4567891315649817020467878943221130691322456498497" : rem factor of 6,840,899
rem Number$ = "54468798756132164897" : rem could be prime check to 50,000,000
rem Number$ = "1234567891" : rem is prime
rem Number$ = "987654321" : rem factor of 3
rem Number$ = "123456789" : rem factor of 3
rem Number$ = "99991" : rem is an prime number
Devide_Number = 1
display_Timer = timer()
Display_Speed = 1000
Dim Return_Value( LEN( Number$ ) )
Max_Length = leN( Number$ )
start:
IF Devide_Number <= 3
Devide_Number = Devide_Number + 1
else
IF Devide_Number => 5 then Devide_Number = Devide_Number + 2
IF Devide_Number = 4 then Devide_Number = Devide_Number + 1
endif
IF Devide_Number => 99999999 then cls 0 : sync : end
current_Number = 0
FOR N = 1 to Max_Length : Return_Value( N ) = 0 : NEXT N
FOR N = 1 to LEN( Number$ )
Return_Value( N ) = 0
current_Number = val( str$( current_Number ) + mid$( Number$ , N ) )
while current_Number >= Devide_Number
current_Number = current_Number - Devide_Number
Return_Value( N ) = Return_Value( N ) + 1
endwhile
NEXT N
IF str$( Devide_Number ) = Number$
cls 0
text 30 , 100 , Number$
text 30 , 140 , str$( Devide_Number ) + " is prime"
sync : suspend for key : end
endif
IF current_Number = 0
cls 0
text 30 , 100 , Number$
text 30 , 140 , "factor: " + str$( Devide_Number )
gosub Print_return_value
sync : suspend for key : end
else
IF TIMER() >= display_Timer + Display_Speed
cls 0
display_Timer = TIMER()
text 30 , 100 , Number$
text 30 , 140 , str$( Devide_Number ) + " is not an factor"
gosub Print_return_value
sync
endif
endif
goto start
Print_return_value:
return_String$ = "" : Found_start = 0
FOR N = Max_Length to 2 step -1
while Return_Value( N ) > 9
Return_Value( N ) = Return_Value( N ) - 10
Return_Value( N -1 ) = Return_Value( N -1 ) + 1
endwhile
NEXT N
FOR N = 1 to Max_Length
IF Found_start = 0 and Return_Value( N ) > 0 then Found_start = 1
IF Found_start = 1 then return_String$ = return_String$ + str$( Return_Value( N ) )
NEXT N
text 30 , 160 , return_String$ + " R " + str$( current_Number )
return