I wrote this program originally in pascal so i had to make a couple of changes.
I am not sure what the maximum number is for a integer in scar.
Letters, #s with decimals, and #s over the maximum number, WILL NOT WORK!
It does compile so...
Please post suggestions or point out errors that i have made.
Version 2 released
I added the boolean and increased the maximum to about 10,000,000,000,000.(10 trillion).
Thanks for Durza998, bullzeye95, JuKKa, Narcle for helping me out.
SCAR Code:
Program PrimeNumberChecker;
{Made by Smithsps}
var
A1, A2, A3 : int64;
CN, CN2, CN3, CN4, UEN : int64;
Z1, Z2, Z3 : string;
end1 : string;
Prime : boolean;
Procedure Prime1;
begin
if (Prime = False) then
begin
Z1 := inttostr(CN4);
Z2 := inttostr(CN3);
writeln('Your number is not prime');
writeln('Divider was: ' + Z1);
writeln('It goes in it '+ Z2 + ' times.');
end;
if (Prime = True) then
begin
writeln('Congratulations, your number was Prime.');
end;
end;
Procedure Mod1;
begin
A1 := UEN div CN;
A2 := A1 * CN;
A3 := UEN - A2;
end;
Procedure Check;
begin
CN := 1;
CN2 := UEN - 1;
repeat
CN := CN + 1;
Mod1;
if (A3 = 0) then
begin
Prime := False;
end;
until (CN2 = CN) or (Prime = False);
CN4 := CN;
CN3 := UEN div CN4;
ClearDebug;
if (UEN = 2) then
Prime := True;
end;
Procedure Begining;
begin
Prime := True;
ClearDebug;
Z3 := readln('Please enter the number you want to check.');
UEN := strtoint64(Z3);
ClearDebug;
end;
Procedure Ending;
begin
writeln('');
writeln('Thank you for using my script. Made by Smithsps');
end1 := readln('Type "Exit" to quit. Type nothing or anything else to continue.');
ClearDebug;
end;
Procedure MasterScript;
begin
repeat
Begining;
Check;
Prime1;
Ending;
until (end1 = 'Exit') or (end1 = 'exit');
end;
begin
MasterScript;
end.