given a natural number N, find a natural number n such that max ((n!)^2 <=N)

Help me out! given a natural number N, find a natural number n such that max ((n!)^2 <=N).

2 comentarios

The term max((n!)^2 <=N) does not make sense. ((n!)^2 <=N is a Logical.
I actually want to find the maimum value of n such that (n^2)!<= N

Iniciar sesión para comentar.

Respuestas (1)

N = 1400;
n = 1;
while prod(1:n)^2 < N
n = n + 1;
end;
n = n - 1

2 comentarios

Better take "log" on both sides:
N = 1400;
logN = log(N);
n = 1;
while 2*sum(log(1:n)) < logN
n = n + 1;
end;
n = n - 1
Best wishes
Torsten.
Thorsten
Thorsten el 20 de En. de 2016
Editada: Thorsten el 20 de En. de 2016
Good point. This allows one to run the code for higher N > 99.

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 19 de En. de 2016

Editada:

el 20 de En. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by