LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To check given number is Factorial of number or not

Solved!
Go to solution

I have a problem, i given some input number n, we have to check whether the no is factorial of some other number or not.

For example 24 if i enter it is a factorial of 4.

Help me

0 Kudos
Message 1 of 7
(6,057 Views)

Hi Ali,

 

I have a problem

What exactly is your problem?

- Do you want to learn LabVIEW? Ask NI!

- Do you want to know how to determine prime numbers? Ask Wikipedia!

- Do you have a problem with your specific VI? Attach it!

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 2 of 7
(6,035 Views)

This is a simple problem, because the possible values are all integers and the function is always increasing and thus has no complicated behavior. The simple way would be to divide by successive increasing integers and if you end up at 1 you started with a factorial, else not.

 

The complication is that only very few factorials can be accurately represented in e.g. DBL or U64, and these can all be calculated nearly instantaneously, so you could simple make a lookup table.

 

How many digits do you allow for the input? You can do math with huge number of digits and get e.g. all 35660 digits of 10000! (exampleSo if you want to allow very large inputs, things get a bit more interesting. What is the allowed range of inputs?

0 Kudos
Message 3 of 7
(6,024 Views)
Solution
Accepted by topic author ali9963

@ali9963 wrote:

I have a problem, i given some input number n, we have to check whether the no is factorial of some other number or not.

For example 24 if i enter it is a factorial of 4.


This sounds familiar...LabVIEW Digest Challenge 2

 

My solution was also the lookup table.  But there are some interesting solutions in there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(5,998 Views)

@crossrulz wrote:
This sounds familiar...LabVIEW Digest Challenge 2

How come I have never heard of that group? 😮 (just joined!)

 


@crossrulz wrote:
My solution was also the lookup table.  But there are some interesting solutions in there.

Would have been interesting to expand it to inputs with thousands of digits. 😄

0 Kudos
Message 5 of 7
(5,972 Views)

@altenbach wrote:

@crossrulz wrote:
This sounds familiar...LabVIEW Digest Challenge 2

How come I have never heard of that group? 😮 (just joined!)


Poor organization of the community?

 

Due note that the challenges are technically only open to Europe, Middle East, India and Africa.  So no prizes for me.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 7
(5,970 Views)
Solution
Accepted by topic author ali9963

@crossrulz wrote:

@altenbach wrote:

@crossrulz wrote:
This sounds familiar...LabVIEW Digest Challenge 2

How come I have never heard of that group? 😮 (just joined!)


Poor organization of the community?

 

Due note that the challenges are technically only open to Europe, Middle East, India and Africa.  So no prizes for me.


We don't need prizes to show them how to really program something 😄

 

Seriously, though, it would be nice to bring back regular (global!) coding challenges.

0 Kudos
Message 7 of 7
(5,957 Views)