20100422, 03:46  #111 
Aug 2006
2·2,969 Posts 
I'm looking at your posts on the other forum. You write:
Code:
#include <math.h> #include <stdio.h> #include <limits.h> #pragma precision=log10l(ULLONG_MAX)/2 typedef enum { FALSE=0, TRUE=1 } BOOL; BOOL is_prime( int p ){ if( p == 2 ) return TRUE; else if( p <= 1  p % 2 == 0 ) return FALSE; else { BOOL prime = TRUE; const int to = sqrt(p); int i; for(i = 3; i <= to; i+=2) if (!(prime = p % i))break; return prime; } } BOOL is_mersenne_prime( int p ){ if( p == 2 ) return TRUE; else { const long long unsigned m_p = ( 1LLU << p )  1; long long unsigned s = 4; int i; for (i = 3; i <= p; i++){ s = (s * s  2) % m_p; } return s == 0; } } int main(int argc, char **argv){ const int upb = log2l(ULLONG_MAX)/2; int p; printf(" Mersenne primes:\n"); for( p = 2; p <= upb; p += 1 ){ if( is_prime(p) && is_mersenne_prime(p) ){ printf (" M%u",p); } } printf("\n"); } Also, I would be wary of the call to sqrt; it may not round properly for sufficiently large numbers. Just for kicks, here's how I'd code the basic trial division prime tester: Code:
int isprime(int p ) { if(!(p&1)) return p == 2; if(p%3 == 0) return p == 3; if(p < 25) return p > 1; int i, to = (int)sqrt(p + 0.5); for(i = 5; i <= to; i += 6) { if (p%i == 0) return 0; if (p%(i+2) == 0) return 0; } return 1; } Last fiddled with by CRGreathouse on 20100422 at 03:51 
20101212, 20:53  #112 
May 2004
New York City
2×2,099 Posts 
Another possibly interesting variation:
2^2 + 3^3 + 5^5 + ... + p^p = 10^{m}K What is the smallest prime p such that the sum of squares of all primes up to p is a multiple of 10 (or 100 or 1000 and so on). (I think somewhere in these series we'll get numeric pointers to empirical evidence connecting some number theoretical conjectures.) 
20101212, 21:19  #113  
Aug 2006
2·2,969 Posts 
Quote:
Why? 

20101212, 21:22  #114 
May 2004
New York City
1066_{16} Posts 
Something big? Now wouldn't that be cool to see ...

20101212, 21:43  #115 
Aug 2006
2·2,969 Posts 

20101212, 21:52  #116 
May 2004
New York City
2·2,099 Posts 
So far, this (sum p^p) sequence is:
11 751 1129 361649 Couldn't have done that without a computer. 
20101213, 01:39  #117  
"Nathan"
Jul 2008
Maryland, USA
3·7·53 Posts 
Methinks your calculator needs new batteries
Quote:
2^2 + 3^3 = 4 + 27 = 31 2^2 + 3^3 + 5^5 = 4 + 27 + 3125 = 3156 2^2 + 3^3 + 5^5 + 7^7 = 826699 The next term brings the sum to 285 billion and change (i.e. 285e9), and the term after that brings the sum to over 303 trillion (i.e. 303e12). Looking at the sum mod 10, we see that 2^2 = 4, 3^3 = 7, 5^5 = 5, 7^7 = 3, 11^11 = 1. This adds up to 0 (mod 10). Hence, 2^2 + 3^3 + 5^5 + 7^7 + 11^11 = 285,312,497,210 would be the first time the sum is divisible by 10. Likely, the way to attack the problem for mod 10^n, would be to ask questions about the residues of p^p (mod 10^n) in general. 

20101213, 02:13  #118 
May 2004
New York City
1066_{16} Posts 
I suppose my batteries would have been sufficient to get
that first term, but for the second I would have needed my homebuilt multiprecision (computerresident) calculator, written in C but currently in mothballs. Does the sum for 361649 really end in four zeros? Maybe those sums should be in the same table. This could get interesting. 
20101213, 02:54  #119 
Aug 2006
2·2,969 Posts 
Five, actually  it will be fourth and fifth on your list:
11, 751, 1129, 361649, 361649, 12462809, 12462809, 1273183931, 1273183931. Would someone check me on these? The repeating entries are freaking me out. Last fiddled with by CRGreathouse on 20101213 at 03:08 Reason: update list 
20101213, 03:32  #120 
May 2004
New York City
2·2,099 Posts 
Well, so far the sequence of sum(p^p)mod(10^n)
(I think it needs a better name) is: 11 751 1129 361649 361649 12462809 12462809 1273183931 1273183931 Any bets that the tenth and eleventh terms are equal, and whether the twelfth breaks THAT pattern? 
20101213, 03:43  #121 
Aug 2006
13462_{8} Posts 
Nothing to 10^10.

Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Regarding Squares  a1call  Miscellaneous Math  42  20170203 01:29 
Basic Number Theory 12: sums of two squares  Nick  Number Theory Discussion Group  0  20161211 11:30 
Integers = sums of 2s and 3s.  3.14159  Miscellaneous Math  12  20100721 11:47 
Sums of three squares  CRGreathouse  Math  6  20091106 19:20 
squares or not squares  m_f_h  Puzzles  45  20070615 17:46 