mersenneforum.org Easy Question
 Register FAQ Search Today's Posts Mark Forums Read

2009-10-02, 02:01   #12
CRGreathouse

Aug 2006

10111001011002 Posts

Quote:
 Originally Posted by R.D. Silverman he did not say that he was a novice programmer; only that he was a novice with C.
True. But his/her decision to not use a loop (or array) and do use a constant to store each integer up to 10 made it clear that [s]he was.

2009-10-02, 03:47   #13
flouran

Dec 2008

2×5×83 Posts

Quote:
 Originally Posted by Unregistered I'm a complete noob when it comes to programming in c, but you have to start somewhere. I ran into a question about factorials. Can you use "n!"? It didnt work for me, I instead went about it the long way, # include int main (void) { int n, n1 = 1, n2 = 2, n3 = 3, n4 = 4, n5 = 5, n6 = 6, n7 = 7, n8 = 8, n9 = 9, n10 = 10, nResult; printf("-n- -n!\n\n"); printf( "%i %2i\n" , n1 , nResult = n1); printf( "%i %2i\n", n2, nResult = n1 * n2); printf( "%i %2i\n", n3, nResult = n1 * n2 * n3); printf( "%i %2i\n", n4, nResult = n1 * n2 * n3 * n4); printf( "%i %2i\n", n5, nResult = n1 * n2 * n3 *n4 * n5); and so on.... } Whats an easier way?
A good but rather outdated discourse that I would refer you to is:
Peter B. Borwein: On the Complexity of Calculating Factorials. J. Algorithms 6(3): 376-380 (1985)

 2009-10-03, 17:24 #14 Xyzzy     "Mike" Aug 2002 3·7·367 Posts
2009-10-03, 17:52   #15
flouran

Dec 2008

2×5×83 Posts

Quote:
 Originally Posted by Xyzzy http://www.willamette.edu/~fruehr/ha...evolution.html

I heartily enjoyed the tenured professor's code

 Similar Threads Thread Thread Starter Forum Replies Last Post petrw1 PrimeNet 7 2013-08-14 13:54 Puzzle-Peter Twin Prime Search 0 2011-06-25 07:41 Uncwilly Puzzles 35 2006-11-15 01:07 fetofs Puzzles 10 2006-11-03 03:29 Mini-Geek Puzzles 3 2006-10-19 17:14

All times are UTC. The time now is 15:43.

Wed Oct 28 15:43:13 UTC 2020 up 48 days, 12:54, 3 users, load averages: 1.94, 1.85, 1.86