What would be a programming language without examples? … just …
- Hello World
- Christmas tree – ASCII-Art
- Search for four digits
- Complex numbers
- Almost perfect numbers
- Sum of divisors
PRINT "HELLO WORLD"
Prints “Hello World” in the output.
Christmas tree – ASCII art
Z = 1 WHILE Z != 0 INPUT "ZEILEN:", Z IF Z = 0 THEN BREAK ENDIF PRINT "" FOR J = Z TO 1 STEP - 1 ZEILE = " " FOR I = 1 TO J ZEILE = ZEILE + " " NEXT FOR K = 1 TO (Z+1-J)*2-1 ZEILE = ZEILE + "#" NEXT PRINT ZEILE NEXT ZEILE = "" FOR L = 1 TO Z+1 ZEILE = ZEILE + " " NEXT ZEILE = ZEILE + "#" PRINT ZEILE PRINT "" WEND
Asks for the number of lines and prints a fir tree in the output.
0 terminates the program.
Reads in a coordinate and saves a circle with radius 100m and 10 points at a distance of 36 degrees in the waypoint list.
Search for four digits
FOR Z = 1 TO 9 FOR A = 1 TO 9 FOR H = 1 TO 9 FOR L = 0 TO 9 C = 0 U = Z * 1000 + A * 100 + H * 10 + L V = A * 1000 + H * 100 + Z * 10 + L W = H * 1000 + A * 100 + Z * 10 + L IF ISSQR(U) = 1 THEN C = C + 1 ENDIF IF ISSQR(V) = 1 THEN C = C + 1 ENDIF IF ISSQR(W) = 1 THEN C = C + 1 ENDIF IF ISSQR(U) = 1 THEN PRINT "ZAHL: "; Z, A, H, L ENDIF NEXT NEXT NEXT NEXT
Four digits are searched for which, when combined accordingly, form three four-digit square numbers.
R = 197 LAT = 50.9621667 LON = 11.03585 C = 0 FOR M = 0 TO 999 FOR S = 1 TO 2 FOR N = 0 TO 999 X = 50 + (57 + M / 1000) / 60 Y = 11 + (S + N / 1000) / 60 D = DISTANCE(A, O, X, Y) IF D <= R THEN C = C + 1 ENDIF NEXT NEXT NEXT PRINT "Points within radius ", R, " are ", C
Searches the number of possible coordinates that lie within a radius R around the coordinate (LAT|LON).
FOR A = 1 TO 9
FOR B = 0 TO 9
Z = A * 10000 + 6790 + B
C = Z / 72
R = MOD(Z, 72)
IF R = 0 THEN
PRINT Z, A,B,C
Someone buys 72 identical products.
These products all cost the same price C and this price is an integer euro amount. (so 1 euro or 2 euros or 3 euros and so on).
The total amount of the purchase price is A679B euros.
Where B is a number from the set of integers from 0 to 9
and A is a number from the set of integers from 1 to 9.
So the total purchase price is five digits.
What are A and B?
And how much does a single product cost now?
DATA 1.91372648, 2.4914364, 3.05909465, 0.71522325
FOR I = 1 TO 2
POLAR(L, X, Y)
Reads one complex number at a time from a block of data in the form of Cartesian coordinates and converts them to their polar form.
Almost perfect numbers
FOR I = 15 TO 99
S = SUM(T) - I
D = I - 4
IF S = D THEN
PRINT I, D, T
What we are looking for are not perfect numbers, but – let us say – “almost perfect numbers”.
They are defined like this:
A natural number n is said to be an “almost perfect number”, if the sum of all its (positive) divisors except itself is smaller than the number n by a certain difference.
Question: what is the next larger almost perfect number A with respect to the difference 4 after 14?
Sum of divisors
FOR I = 1 TO 999
S = SUM(T) - I
IF S > I THEN
PRINT I, S, T
There are indeed also natural numbers for which the sum of all their (positive) divisors except themselves is greater than the number itself. What is the smallest natural number B for which this is the case?