MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fastest way to calculate Factorial of 285714?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Other Technical Topics
View previous topic :: View next topic  
Author Message
deepeshk79
Beginner


Joined: 20 Jun 2003
Posts: 112
Topics: 48
Location: Bangalore

PostPosted: Sun Jul 02, 2006 5:34 am    Post subject: Fastest way to calculate Factorial of 285714? Reply with quote

Hi All,

This is a general question in computers

Quote:


What is the fastest way to compute 285714! (i.e. the factorial of 285714)?



Any thoughts ....

Deepesh
Back to top
View user's profile Send private message AIM Address
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Sun Jul 02, 2006 6:11 am    Post subject: Reply with quote

Here is my REXX solution:
Code:
/* REXX */                   
                             
NUM = 285714                 
                             
SAY FACT(NUM)                 
                             
EXIT                         
                             
FACT: PROCEDURE               
PARSE ARG N                   
F = 1                         
DO J = 2 TO N; F = F * J; END
RETURN F                     


O.
________
Honda CBR900RR


Last edited by ofer71 on Sat Feb 05, 2011 11:36 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun Jul 02, 2006 1:58 pm    Post subject: Reply with quote

deepeshk79,

Do you really need that Big of a number? Anyway check this link which explains some of the techniques

Fast Factorial Functions

Btw cobol offers an Intrinsic function FACTORIAL , but is only limited to 28! or 29! with extend compiler option

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
deepeshk79
Beginner


Joined: 20 Jun 2003
Posts: 112
Topics: 48
Location: Bangalore

PostPosted: Mon Jul 03, 2006 7:33 am    Post subject: Reply with quote

Thanks Kolusu for the link.
Also Ofer thanks for your REXX code.
Back to top
View user's profile Send private message AIM Address
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Jul 03, 2006 1:31 pm    Post subject: Reply with quote

deepeshk79,
Have you observed something magical about the number, 285714/2 ?

Take 142857. Multiply it by 2, note the product. Then by 3, note the product. Continue till 6. You will see that the product always consists of the digits 1,4,2,8,5 and 7 rotated in a cyclical fashion.

What happens when multiplied by 7 ? Another interesting number !

Enjoy !

Cool
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Tue Jul 04, 2006 1:10 am    Post subject: Reply with quote

That's because 142857 is a Cyclic Number. To read more about it, refer to the following link.

O.
________
[URL=http://www.bmw-tech.org/wiki/BMW_3_Series_(E46)]3 Series (E46)[/URL]
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Other Technical Topics All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group