Showing posts with label prime numbers. Show all posts
Showing posts with label prime numbers. Show all posts

Tuesday, January 1, 2019

Celebrating the New Year With 2019: 19 Ways to Mathematically Express 2019

Celebrating the New Year With 2019

HAPPY NEW YEAR!!!



19 Ways to Mathematically Express 2019

2019 = 3 * 673  (Prime Factorization)

2019 = 2^10 + 2^9 + 2^8 + 2^7 + 2^6 + 2^5 + 2 + 1

2019 = 3 + 2 * (3^6 + 3^5 + 3^3 + 3^2)

2019 = 42^2 + 4^4 - 1

2019 = 41^2 + 7^3 - 5

2019 = 4^5 + 3^6 + 2^8 + 10

2019 = 11^3 + 5^4 + 2^6 - 1

2019 = 12^3 + 17^2 + 2

2019 = int(10^3.3) + int(e^3) + 2^2   (e = 2.718281828...,  int: integer function)

2019 = 2 * (10^3 + 9.5)

2019 = 3^7 - 13^2 + 1

2019 = 4 * 505 - 1

2019 = 2 * 6! + 4 * 5! + 16 * 3! + 3

2019 = (10^4 + 19 * 5) / (2^2 + 1)

2019 = (13^4 - 12^3 - 9^3 + 12^2 - 1) / (2^2 + 3^2)

2019 = (2^13 + 3^8 + 4^5 + 5^3 + 6^3 + 34) / 8

2019 = 50 * 19 + 50 * 18 + 9 * 17 + 16

2019 = 25 * 19 + 25 * 18 + 26 * 13 + 71 * 11

2019 = √(4 * 10^6 + 7 * 10^4 + 6 * 10^3 + 3 * 10^2 + 6 * 10 + 1)




Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Wednesday, December 19, 2018

HP Prime and TI-84 Plus: Sieve of Eratosthenes

HP Prime and TI-84 Plus: Sieve of Eratosthenes

Introduction

The program SIEVEMIN shows a miniature version of the famous Sieve of Eratosthenes.  The Sieve of Eratosthenes is a Greek algorithm that determines prime numbers from 2 to N through eliminating multiplies.

Algorithm:

1.  List all integers from 1 to n.  Of course, you choose what n is. 

2.   1 is not a prime number, hence eliminate 1. 

3.  Start with 2.  Eliminate multiple of 2, but not 2 itself.

4.  Then do step 3, but with multiples of 3, but not 3 itself.

5.  Then do step 5, but with multiples of 5, but not 5 itself. 

6.  Continue on with the next available number until there are no multiples remaining.  At the end, you have all the prime numbers from 1 to n.

Most sieves will demonstrate the algorithm from 1 to 100.  However, to fit the calculator screens, SIEVEMIN finds all the prime numbers from 1 to 49. 

HP Prime Program: SIEVEMIN 



sub1(); // subroutine

EXPORT SIEVEMIN()
BEGIN
// 2018-12-18 EWS
// Mini Sieve
HFormat:=0; // standard
PRINT();
PRINT("Mini Sieve");
WAIT(1);
LOCAL M0,T,R,C,K;
T:=1;
M0:=MAKEMAT(0,7,7);

FOR R FROM 1 TO 7 DO
FOR C FROM 1 TO 7 DO
M0(R,C):=T;
T:=1+T;
END;
END;

sub1(M0);

M0(1,1):=0;
FOR K FROM 2 TO 7 DO
FOR R FROM 1 TO 7 DO
FOR C FROM 1 TO 7 DO
IF FP(M0(R,C)/K)==0 AND 
M0(R,C)>K THEN
M0(R,C):=0;
sub1(M0);
END;
END;
END;
END;

// end of program

END;

sub1(M1)
BEGIN
PRINT();
LOCAL I;
FOR I FROM 1 TO 7 DO
PRINT(row(M1,I));
END;
WAIT(0.5);
END;

TI-84 Plus CE Program:  SIEVEMIN



"2018-12-11 EWS"
Disp "MINI SIEVE OF","ERATOSHENES","TI-84 PLUS CE"
Float
Wait 1
{7,7}→dim([J])
1→T
For(R,1,7)
For(C,1,7)
T→[J](R,C)
1+T→T
End
End
ClrHome
Disp [J]
Wait 1

0→[J](1,1)
For(K,2,7)
For(R,1,7)
For(C,1,7)
If fPart([J](R,C)/K)=0 and [J](R,C)>K
Then
0→[J](R,C)
ClrHome
Disp [J]
Wait .5
End
End
End
End

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Sunday, October 23, 2016

Fun with Primes: Sum of Primes

Fun with Primes:  Sum of Primes

Primes Composed of a Sum of Primes

Separated by 2

5 = 2 + 3
7 = 2 + 5
13 = 2 + 11
19 = 2 + 17
43 = 2 + 41
61 = 2 + 59
151 = 2 + 149
193 = 2 + 191

Other Sums

23 = 2 + 3 + 5 + 13
31 = 7 + 11 + 13
47 = 5 + 19 + 23
59 = 7 + 23 +29
71 = 3 + 31 +37
79 = 13 + 19 +47
79 = 5 + 31 +43
83 = 11 + 31+ 41
101 = 3 + 31 + 67
107 = 19 + 29 +59
109 = 3 + 47+ 59
113 = 11 + 41 +61
127 = 17 + 43 + 67
127 = 2 + 29 + 37 + 59
131 = 41 + 43 + 47
151 = 11 + 67 + 73
157 = 13 + 47 + 97
173 = 43 + 59 + 71
199 = 43 + 47 + 109
223 = 71 + 73 + 79
233 = 59 + 67 + 107
311 = 29 + 47 + 59 + 67 + 109

Primes Composed of a Sum and Product of Primes

31 = 2 * 5 + 7 * 3
43 = 17 + 2 * 13
47 = 2 * 7 + 3 * 11
61 = 2 * 11 + 3 *13
79 = 2 * 7 + 5 * 13
83 = 47 + 2 * (5 + 13)
89 = 7 + 2 * 41
149 = 2 * 17 + 5 * 23
149 = 2 * 59 + 31
163 = 2 + 7 * 23

What other combinations you find? 

Eddie

This blog is property of Edward Shore, 2016.



Saturday, October 22, 2016

HP Prime: Fun with Primes

HP Prime:  Fun with Primes

Prime Numbers

A positive integer is a prime number if there the only integers that can divide that number evenly (without remainder) is 1 and itself.

Fun facts:

*  1 is not a prime number.
*  2 is the only even prime number.
*  5 is the only prime number that ends in 5. 
*  No prime number has a 0, 4, 6, or 8 as the last digit.

Sum of the Fist n Primes

Let p be a prime number.  That is, p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, …}

The sum of the first prime numbers is:  Σ p_k from k = 1 to n

HP Prime Program SPRIMES:  Sum of the First n Primes
EXPORT SPRIMES(n)
BEGIN
// 2016-10-22 EWS
// Sum of the first n primes

LOCAL t,p,k;

IF n≤1 THEN
RETURN 2;
ELSE
t:=2;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p+t;
END;

RETURN t;
END;
END;




Sum of the First n Prime Reciprocals

Σ 1/(p_k) from k = 1 to n


HP Prime Program ISPRIMES:  Sum of first n Prime Reciprocals
EXPORT ISPRIMES(n)
BEGIN
// 2016-10-22
// Sum of reciprocal of primes

LOCAL t,p,k;
n:=IP(n);

IF n≤1 THEN
RETURN 2;
ELSE
t:=2¯¹;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p¯¹+t;
END;

RETURN t;
END;


END;

It does not appear that there series of sums do not converge as n approaches ∞ (infinity).

ISPRIMES(25) returns 1.80281720104
ISPRIMES(50) returns 1.96702981491
ISPRIMES(100) returns 2.10634212145
ISPRIMES(10000) returns 2.70925824876



Product of the First n Prime Reciprocals

Π 1/(p_k) from k = 1 to n

HP PRIME Program IPPRIMES
EXPORT IPPRIMES(n)
BEGIN
// 2016-10-22
// Product of reciprocal of primes

LOCAL t,p,k;
n:=IP(n);

IF n≤1 THEN
RETURN 2;
ELSE
t:=2¯¹;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p¯¹*t;
END;

RETURN t;
END;
END;

Unlike ISPRIMES, IPPRIMES approaches 0 as n approaches ∞.

IPPRIMES(25) returns 4.33732605429E-37
IPPRIMES(50) returns 5.24156625851E-92
IPPRIMES(100) returns 2.12227225409E-220
IPPRIMES(10000) returns 0



This blog is property of Edward Shore, 2016.



Tuesday, February 16, 2016

HP Prime: Carmichael Numbers (Update 2/21/2016)

HP Prime:  Carmichael Numbers

Introduction

An integer n is a Carmichael number (1910) when the following holds:

a^n ≡ a mod n

(or for a>0 and n>0)

a^n – integer(a^n/n) * n  = a

For all integers a.

The program ISCARMICHAEL tests whether an integer n qualifies as a Carmichael number based on the Korselt’s Criterion:

1.  n is a positive, composite integer.  That is, n can be factored into a multiplication of prime numbers.
2.  n is square-free.  That is, √n is not an integer.
3. For each prime factor p dividing n (not 1 or n), the following is true: (p-1) divides (n-1) evenly (without fraction). 


Update:  I was mistaken about the definition of squarefree.  A squarefree integer are integers that are not divisible by perfect squares (I thought the number was square free itself).  I am to update ISCARMICHAEL this week.  Apologizes and many appreciations to Hank for pointing this out to me.  -  EWS 

HP Prime Program ISCARMICHAEL  (Updated 2/21/2016)

EXPORT ISCARMICHAEL(n)
BEGIN
// EWS 2016-02-21
// Thanks: Hank
LOCAL l1,s,flag,k;
LOCAL vect;
flag:=0;

// composite test
IF isprime(n)==1 THEN
RETURN 0; KILL;
END;

// setup
vect:=ifactors(n);
l1:=SIZE(vect);
s:=l1(1);


// square-free number test
FOR k FROM 2 TO s STEP 2 DO
IF vect(k)>1
THEN
flag:=1; BREAK;
END;
END;

// factor test

FOR k FROM 1 TO s STEP 2 DO
IF FP((n-1)/(vect(k)-1))≠0
THEN
flag:=1; BREAK;
END;
END;

// final result
IF flag==0 THEN
RETURN 1;
ELSE
RETURN 0;
END;


END;

Notes:
The commands isprime and ifactors are generated from the CAS-Integer (Options 6 then 1 for isprime; option 3 for ifactors) submenu.  However, I think in order for this program to work properly, the “CAS.” must be deleted and the command should be in all-lowercase.

Examples:

ISCARMICHAEL(561) returns 1.  561 is a Carmichael number.  The prime factors of 561 are 3, 11, 17.

ISCARMICHAEL(778) returns 0, hence 778 is not a Carmichael number.  The prime factors of 778 are 2 and 389.

Source:

Crandall, Richard and Pomerance, Carl.  Prime Numbers: A Computational Perspective  2nd Ed.  Springer: New York.  2005

Eddie



This blog is property of Edward Shore.  2016

Saturday, November 8, 2014

My Morning at Honnold/Mudd Library: 2014-11-08 (Game Shows, Bravias Lattice, Prime Numbers)

My Morning at Honnold/Mudd Library

Honnold/Mudd Library - Claremont, CA


What I love about visiting the mathematics and science sections in a university library is that there is a feast of information.  Every time, there is something new to learn.   Here are some notes from today’s visit:

Game Shows and Winning

Source:  John Haigh.  “Taking Chances: Winning with Probability”  2nd Edition Oxford Press: 2003

Haigh introduces two central ideas of probability:  exclusive events and independence.  Is it impossible for two events to occur simultaneously?  Does one event have any effect on another?  Let’s explore some popular concepts of probability found in game shows.

“Find the Lady” – also known as the “Monty Hall Problem”.  You have three boxes, two are worthless and one has the prize.  After the contestant selects the box, the host shows one of the boxes that are worthless.  Statistically, if the contestant switches their initial choice, the contestant doubles the chance of winning.  That is, since the contestant initially is incorrect 2/3 of the time, and the host shows one of the incorrect boxes; the contestant who switches has a 2/3 chance of switching from a losing box to the winning box.

“Showcase Showdown” (The Price is Right) – spinning last may not be the most advantageous place to be.  It depends on the scores of the first two spinners, and the chance of getting the best score. 

“Who Wants to be a Millionaire” – In the classic structure of the game, before the time clock and the shuffle format, contestants were offered three lifelines:  Ask the Audience, 50:50, and Phone a Friend.  Haigh suggests using the lifelines in this order: 50:50, Ask the Audience, and Phone a Friend.  The risk between higher level questions increase as the game goes on.  

“Blockbusters”

A two-person team (white) goes against an individual player (blue in the UK, red in the US).  For each question the team has 2/3 chance of getting the question correctly, but will have to answer a minimum of five question correctly, while the individual can win the game as a few as four correct answers.

My calculation:  assuming that there are no blocks, the probability that the team wins with five consecutive answers is (2/3)^5 = .13169 versus (1/3)^4 = .01235. 

Ideal Crystals and Bravais Lattices

Source:  M.G. Cottam and D.R. Tilley  “Introduction to Surface and Superlattice Excitations”  Cambridge University Press:  Cambridge.  1989.

Ideal crystals are described as a basis of atoms (or ions) located on each point of a lattice, which is defined as a regular periodic array in space.  In an ideal crystal, all the lattice points are equivalent.

Each lattice is defined by the non-coplanar vector a1, a2, and a3.  That is, a1, a2, and a3 do not lie on one specific plane.  The space lattice is formed through a collection of vectors, symbolized as R, as:

R = n1*a1 + n2*a2 + n3*a3, where n1, n2, and n3 are integers. 

Since the ideal crystal has translational symmetry, the transition f(r+R)=f(r) is satisfied for all points in space, which such a point is represented by r. 

The reciprocal lattice vector of R, symbolized by Q, takes the form:

Q = v1*b1 + v2*b2 + v3*b3, where v1, v2, and v3 are integers, and

b1 = ((2*π*a2) x a3) / dot(a1, a2 x a3)
b2 = ((2*π*a3) x a1) / dot(a1, a2 x a3)
b3 = ((2*π*a1) x a2) / dot(a1, a2 x a3)

Where x represents the vector cross product and dot(v,u) represents the dot product.
Two-Dimensional Lattices

Let a1 and a2 be two translation vectors and the set R be defined as:

R = n1*a1 + n2*a2, where n1 and n2 are integers

The ends points of R from what is called the Bravais lattice.  There are five Bravais lattices which take the shape of one of these five forms:

1.    Square, |a1| = |a2|, θ = 90°
2.    Primitive Rectangle (general rectangle), |a1| ≠ |a2|, θ = 90°
3.    Centered Rectangle (rhombic), |a1| ≠ |a2|, θ = 90ׄ°
4.    Hexagonal, |a1| = |a2|, θ = 60° or 120°
5.    Oblique, all other cases

Cottam and Tilley illustrates the concept of bulk and surface excitation by using how Rayleigh’s descriptions of waves in a semi-infinite isotropic elastic medium.  In searching for plane-wave solution, in which the wave propagates parallel to the surface with vector q with velocity v and frequency w:

f’’(z) – (q^2 – w^2/v^2)*f(z) = 0

If q^2 < w^2/v^2, we have a bulk wave where

f(z) = B1*e^(i*√(w^2/v^2-q^2)*z) + B2*e^(-i*√(w^2/v^2-q^2)*z) where B1 and B2 are constants.

If q^2 > w^2/v^2, we have a decaying surface wave where

f(z) = B3*e^(√(q^2-w^2/v^2)*z)


Prime Number Goodies

Source:  Richard Carndall and Carl Pomeance.  “Prime Numbers: A Computational Perspective.  Second Edition” Springer.  2005

Twin Primes:  

Two primes that differ by 2.  Examples include 3 and 5, 29 and 31, and 311 and 313.  Is there an upper bound on twin primes, or is there an infinite set of pairs? 

V. Brun showed the upper bound for the number of twin prime sets under the integer x is:

‘π(x) = O(x*(ln ln x/ln x)^2) -> x*(ln x)^-2

Brun also showed that the sum of the reciprocal of the twin primes is finite.  That sum is denoted as the Brun constant which is:

B = (1/3 + 1/5) + (1/5 + 1/7) + (1/11 + 1/13) + …

The Brun constant is at least 1.71077 (using twin primes from 1 to 1,000,000).  As imagined, this series converges slowly.

Formulas to Produce Primes:

Euler used the polynomial x^2 + x + 41 to produce primes, which worked for all integers 0 to 39.  After x = 39, the polynomial continues produce primes at a remarkable probability. 

Mersenne Primes:

Mersenne primes, in the form of 2^q – 1 where q is a prime greater than 2.  It has been proven that if 2^q – 1 is prime, then so is q.  This form does not always produce primes (see q = 11 or q = 23).  In fact, the distribution of Mersenne primes gets scarce quickly as q increases.

Perfect numbers, integers in which the sum of its divisors except itself equals that integer (example: 6 = 1 + 2 + 3), can be characterized by Euler and Euclid:

An even number is perfect if and only if n = 2^(q-1)*(2^q-1) where 2^q-1 is prime.

Quadratic Residues:

The integer a is said to be a quadratic residue of coprime integer m if the congruence

x^2 ≡ a mod m

can be solved such as x is an integer and gcd(a, m) = 1. 

For example, 19 is a quadratic residue mod 5 since 19 mod 5 = 4 = 2^2 and gcd(19,5) = 1.

The next two basic definitions play a role in solving polynomials and equations involving prime numbers.

Legendre Symbol defined as (a/p) [normally written vertically]:

Let p be an odd prime.  Then:

(a/p) = legendresymbol(a,p) =
0 if a ≡ 0 mod p
1 if a is a quadratic residue of p
-1 if a is not a quadratic residue of p

Example:  p = 19.  The Legendre symbols of (4/19), (5/19), and (19/19) are 1, -1, and 0, respectively. (corrected on 2014-11-10 - with apologizes)

Jacobi Symbol defined as (a/m) [normally written vertically]:

Let m be any odd integer and a be any integer.  Then:

(a/m) = jacobisymbol(a, m) =  product( legendresymbol( a, prime factor of m )).

Example:  m = 27 = 3 * 9, a = 55

Jacobisymbol(55, 27) =

Legendresymbol(55, 3) * legendresymbol(55, 9) = 1 * 1 = 1

Is it shown that jacobisymbol(a, m) = 0 if and only if gcd(a, m) > 1.


Enjoy!  

Eddie

Blog Entry # 402

This blog is property of Edward Shore.  2014


HP 15C: The I Squared Rule and HHC 2026

HP 15C: The I Squared Rule and HHC 2026 HHC 2026 Videos Before we start, the videos for HHC 2026 are up! Please take a look, ev...