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 Comments

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

Sign in to comment.

Answers (1)

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

2 Comments

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.
Good point. This allows one to run the code for higher N > 99.

Sign in to comment.

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

Asked:

on 19 Jan 2016

Edited:

on 20 Jan 2016

Community Treasure Hunt

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

Start Hunting!