A
A
Alexander Sobolev2021-04-08 12:38:19
Pascal
Alexander Sobolev, 2021-04-08 12:38:19

Turbo Pascal How to count the numbers in the ones place?

Hello!
They turned to me with a request to evaluate the solution of the problem for which two people were slapped. Everything seems to be correct, but why the deuce is not clear .. or maybe I don’t see something?

Task:
Calculate the number of numbers in the range from 11607 to 55176 which have the number 1 or the number 8 in the ones place

Solution:

Program urok;
var i, kol :integer;
begin
kol:=0;
for i:= 11607 to 55176 do if ( ((i mod 100) div 1 = 1) or((i mod 100) div 1 = 8)) then begin kol:=kol+1; writeln('Есть подходящее число: ',i, '. Текущее количество чисел: ', kol);  end;
writeln(' Общее количество чисел: ', kol);
end.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VitalyChaikin, 2021-04-08
@san_jorich

Two ? There would be a stake! A masterpiece like (i mod 100) div 1 = 8 is just beautiful :)
if( i mod 10 ) = 8 then// ( i mod 10 ) = get the modulo 10 which is the last digit of i

C
Cooler2, 2021-04-11
@Cooler2

And if it were not up to 55176, but up to 551760000 - also run like this in a cycle?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question