mersenneforum.org  

Go Back   mersenneforum.org > New To GIMPS? Start Here! > Information & Answers

Reply
 
Thread Tools
Old 2009-10-02, 02:01   #12
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

10111001011002 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
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.
CRGreathouse is online now   Reply With Quote
Old 2009-10-02, 03:47   #13
flouran
 
flouran's Avatar
 
Dec 2008

2×5×83 Posts
Default

Quote:
Originally Posted by Unregistered View Post
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 <stdio.h>

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)
flouran is offline   Reply With Quote
Old 2009-10-03, 17:24   #14
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

3·7·367 Posts
Default

http://www.willamette.edu/~fruehr/ha...evolution.html
Xyzzy is offline   Reply With Quote
Old 2009-10-03, 17:52   #15
flouran
 
flouran's Avatar
 
Dec 2008

2×5×83 Posts
Default

Quote:
Originally Posted by Xyzzy View Post

I heartily enjoyed the tenured professor's code
flouran is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manual Results Question ... an easy one. petrw1 PrimeNet 7 2013-08-14 13:54
A probably easy question about PFGW and twins Puzzle-Peter Twin Prime Search 0 2011-06-25 07:41
4 not so easy pieces? Uncwilly Puzzles 35 2006-11-15 01:07
Another easy one fetofs Puzzles 10 2006-11-03 03:29
Easy 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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.