Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
60
Task/Esthetic-numbers/XPL0/esthetic-numbers.xpl0
Normal file
60
Task/Esthetic-numbers/XPL0/esthetic-numbers.xpl0
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
proc NumOut(N); \Display N in the current Base
|
||||
int N, R;
|
||||
[N:= N/Base;
|
||||
R:= rem(0);
|
||||
if N # 0 then NumOut(N);
|
||||
if Base <= 10 then
|
||||
ChOut(0, R+^0)
|
||||
else
|
||||
ChOut(0, if R < 10 then R+^0 else R-10+^A);
|
||||
];
|
||||
|
||||
func Esthetic(N); \Return 'true' if adjacent digits differ by 1
|
||||
int N, D, D0;
|
||||
[N:= N/Base;
|
||||
D0:= rem(0);
|
||||
while N # 0 do
|
||||
[N:= N/Base;
|
||||
D:= rem(0);
|
||||
if D = D0 then return false;
|
||||
if abs(D-D0) > 1 then return false;
|
||||
D0:= D;
|
||||
];
|
||||
return true;
|
||||
];
|
||||
|
||||
int Count, N;
|
||||
[for Base:= 2 to 16 do
|
||||
[Text(0, "Base "); IntOut(0, Base); Text(0, ": ");
|
||||
Count:= 0; N:= 1;
|
||||
loop [if Esthetic(N) then
|
||||
[Count:= Count+1;
|
||||
if Count >= Base*4 then
|
||||
[NumOut(N); ChOut(0, ^ )];
|
||||
if Count >= Base*6 then quit;
|
||||
];
|
||||
N:= N+1;
|
||||
];
|
||||
CrLf(0);
|
||||
];
|
||||
Base:= 10;
|
||||
Text(0, "Base 10 numbers between 1000 and 9999:^m^j");
|
||||
Count:= 0;
|
||||
for N:= 1000 to 9999 do
|
||||
[if Esthetic(N) then
|
||||
[Count:= Count+1;
|
||||
NumOut(N); ChOut(0, ^ );
|
||||
if rem(Count/16) = 0 then CrLf(0);
|
||||
];
|
||||
];
|
||||
CrLf(0);
|
||||
Text(0, "Base 10 numbers between 1.0e8 and 1.3e8:^m^j");
|
||||
Count:= 0;
|
||||
for N:= 100_000_000 to 130_000_000 do
|
||||
[if Esthetic(N) then
|
||||
[Count:= Count+1;
|
||||
NumOut(N); ChOut(0, ^ );
|
||||
if rem(Count/9) = 0 then CrLf(0);
|
||||
];
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue