Created
July 5, 2018 18:34
-
-
Save Tricky1975/79cb1b16d3d4694a595e6def77cd802f to your computer and use it in GitHub Desktop.
Quick prime 2 till 100 calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ --- START LICENSE BLOCK --- | |
*********************************************************** | |
primes.pas | |
This particular file has been released in the public domain | |
and is therefore free of any restriction. You are allowed | |
to credit me as the original author, but this is not | |
required. | |
This file was setup/modified in: | |
2018 | |
If the law of your country does not support the concept | |
of a product being released in the public domain, while | |
the original author is still alive, or if his death was | |
not longer than 70 years ago, you can deem this file | |
"(c) Jeroen Broks - licensed under the CC0 License", | |
with basically comes down to the same lack of | |
restriction the public domain offers. (YAY!) | |
*********************************************************** | |
Version 18.07.05 | |
--- END LICENSE BLOCK --- } | |
program primes; | |
var | |
hveld:array[0..100] of integer; | |
i1,i2:integer; | |
uitkomst:integer; | |
begin | |
for i1:=1 to 100 do hveld[i1]:=0; | |
for i1:=1 to 100 do for i2:=1 to 100 do begin | |
uitkomst:=i1*i2; | |
if uitkomst<=100 then hveld[uitkomst]:=hveld[uitkomst]+1 | |
end; | |
writeln('primes = {'); | |
for i1:=2 to 100 do begin | |
if hveld[i1]=2 then writeln(#9,i1,',') | |
end; | |
writeln('}') | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not much... I just used this program to generate a quick Lua script coming up with all prime numbers from 2 till 100...
Any Lua parser should pick this the output it generates nicely... I just made this pre-calculation in Pascal to prevent slowdowns in the Lua script... Or for fun, as I used to be as Pascal programmer, so coding in Pascal is a bit nostalgic for me.
(The code has only been tried in Free Pascal, but it should work in Turbo Pascal as well) :)