-
program divided;var n,i,s:integer;begin s:=0;counters, which are used to count about a number of numbers; readln(n);Enter the original number; for i:
1 to n do if n mod i=0 then begin s:=s+1; write(i:5); end;Let i start looking from 1 to n, and once you find that it is divisible by n, it is the divisor of n, and the counter is further one; writeln; write(s);Output the approximate number in the next row (i.e. the final result of the counter); readln;Wait for the user to enter a carriage return to exit the program.
end.
-
Up to 2 (n-1)-1 , when n is larger there will be a lot of repeating divisors (e.g. *3 this is repeated).
That is, it needs to be deduplicated!
-
Use this number firstRepresentation of the product of equal prime numbers, for example.
Then add one to the exponents of each prime number and multiply them to be the approximate number of this number, such as (3+1)*(1+1)=4*2=8, which means that 24 has 8 divisors.
-
varn,i,ans:integer;
beginreadln(n);ans:=0;
Read in, and set the counter to 0
fori:=1ton
doifnmod
i=0then
inc(ans);
Cycle from 1 to n.
Find a respectful one, and add a number of his factors to the counter, and I will accompany you.
writeln(ans);
The most stupid output result.
end.
-
function add(f:longint):longint;
varii,ss:longint;
beginfor ii:=1 to n do
if f mod ii=0 then ss:=ss+ii;
add:=ss;
end;This is the sum of the non-repeating factor.
Example: add(18)=39
Note: The upstairs program is the same as this one, but I am better at it, and the time and space complexity is higher than mine).
dividing line**********==function add(f:longint):longint;
varii,ss:longint;
beginfor ii:=2 to trunc(sqrt(f)) dowhile f mod ii=0 do beginss:=ss+ii;
f:=f div ii;
end;add:=ss;
end;This is the sum of the prime factors after breaking them down.
Example: add(18)=8
Dividing line**********== Note: I didn't compile the above program, so it said...
-
Find the greatest common divisor of two integers (tossing and dividing).
The procedure is as follows: varm, n : integer;
function fac(i, j:integer):integer;
beginif j=0 then begin fac:=i;exit;end;
fac:=fac(j ,i mod j);
end;begin
readln(n, m);
writeln(fac(n,m));
end.or var
a,b:integer;
procedure qw(a,b:integer);
varv:integer;
beginif a mod b=0 then writeln(b)else if b mod a=0 then writeln(a)else
beginv:=a;
a:=a mod b;
b:=b mod v;
qw(a,b);
end;end;
beginreadln(a,b);
qw(a,b);
readln;
end.
-
Put the 1 in line 3...n read 1...10 (for a fixed value, all variables under var will think your array is quite large, more than the computer can handle).
-
Toss and turn divides, the big one is divided by the small one.
-
I would like to add that in order to get a full score, you need to use high-precision calculations.
It seems that no, mathematicians and their computers in various countries are still trying to find larger prime numbers. If there is an equation, do you still have to find it this way? >>>More
As a simple example, the decomposed prime factors of 12 can be as follows: 12 = 2x2x3 = 4x3 = 1x12 = 2x6, where 1, 2, 3, 4, 6, and 12 can be said to be the factors of 12, that is, the multiplication of several numbers is equal to a natural number, then these numbers are the factors of this natural number. In 2, 3, 4, 2 and 3 are prime numbers, which are prime factors, and 4 is not prime numbers. >>>More
For multiplication problems, just multiply that number by a fraction.
How to multiply the calculator with the same numberFirst calculate 2*2= and then press m+, in an 3*3=, in press m+, in press 4*4=, then press m+, and then press mrc is the result. was the dead body?and WHO I >>>More
Percentage practice questions.
1. A is 2, B is 3, A is B ( ) B is a ( ) A is the sum of A and B ( ) B is the sum of A and B ( ) How many percent is in parentheses). >>>More