program RandomIntegers;
uses
SysUtils;
var
n, M, i, x, y: Integer;
begin
// Input for number of random integers and the maximum limit M
Write('Enter the number of random integers (n): ');
ReadLn(n);
Write('Enter the maximum value (M): ');
ReadLn(M);
Randomize; // Initialize random number generator
for i := 1 to n do
begin
x := Random(M + 1); // Generate a random integer between 0 and M
// Apply the function based on whether x is odd or even
if x mod 2 = 0 then
y := x * x * x // Cube for even x
else
y := x; // Same value for odd x
// Display x and corresponding y
WriteLn('x = ', x, ', y = ', y);
end;
end.
cHJvZ3JhbSBSYW5kb21JbnRlZ2VyczsKCnVzZXMKICBTeXNVdGlsczsKCnZhcgogIG4sIE0sIGksIHgsIHk6IEludGVnZXI7CgpiZWdpbgogIC8vIElucHV0IGZvciBudW1iZXIgb2YgcmFuZG9tIGludGVnZXJzIGFuZCB0aGUgbWF4aW11bSBsaW1pdCBNCiAgV3JpdGUoJ0VudGVyIHRoZSBudW1iZXIgb2YgcmFuZG9tIGludGVnZXJzIChuKTogJyk7CiAgUmVhZExuKG4pOwogIFdyaXRlKCdFbnRlciB0aGUgbWF4aW11bSB2YWx1ZSAoTSk6ICcpOwogIFJlYWRMbihNKTsKCiAgUmFuZG9taXplOyAvLyBJbml0aWFsaXplIHJhbmRvbSBudW1iZXIgZ2VuZXJhdG9yCiAgCiAgZm9yIGkgOj0gMSB0byBuIGRvCiAgYmVnaW4KICAgIHggOj0gUmFuZG9tKE0gKyAxKTsgLy8gR2VuZXJhdGUgYSByYW5kb20gaW50ZWdlciBiZXR3ZWVuIDAgYW5kIE0KICAgIAogICAgLy8gQXBwbHkgdGhlIGZ1bmN0aW9uIGJhc2VkIG9uIHdoZXRoZXIgeCBpcyBvZGQgb3IgZXZlbgogICAgaWYgeCBtb2QgMiA9IDAgdGhlbgogICAgICB5IDo9IHggKiB4ICogeCAvLyBDdWJlIGZvciBldmVuIHgKICAgIGVsc2UKICAgICAgeSA6PSB4OyAvLyBTYW1lIHZhbHVlIGZvciBvZGQgeAogICAgCiAgICAvLyBEaXNwbGF5IHggYW5kIGNvcnJlc3BvbmRpbmcgeQogICAgV3JpdGVMbigneCA9ICcsIHgsICcsIHkgPSAnLCB5KTsKICBlbmQ7CmVuZC4K