Answer to Question #23033 in Delphi | Pascal for Jack Lee

Question #23033
Free Pascal assignment.

Basically, the task is:

We're given integer N. For integer D > 0 we say that he is divisor for N, if D divides N. What is the arithmetic mean of all the divisors of the given number N?

Input: One and only row of the standard input contains integer N (1<=N<=10^9).

Output: In a single line of standard output to print arithmetic mean of divisors given natural number. Number printed with an accuracy of two decimal places.

Please, I need help.
1
Expert's answer
2013-01-30T09:17:41-0500
program pr1; USES CRT;
var N,k,i:integer; s:real;
begin CLRSCR;
readln(N);
for i := 1 to N do
if (N mod i = 0) then begin
s:=s+i;
k:=k+1;

end;
s:=s/k;
write (s:9:2);
end.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS