Divisibility Testing for Prime Numbers

In summary, the conversation discusses different methods of divisibility testing for various numbers, specifically primes. The original question is about finding a method to determine if a large number is divisible by a prime number, using the example of 12783461236 and 97. One suggestion is to use the last digit, multiply by 29, and subtract from the rest to see if the result is divisible by 97. However, it is noted that in general, these types of divisibility tests may require more effort than traditional division. The conversation also mentions building a computer program to perform divisibility testing and suggests looking into arbitrary precision arithmetic for more information. The purpose of the program is for personal learning and not related to cryptography.
  • #1
Moni
181
1
We've seen divisibility testing for different numbers...for 2,3,4,5,7,11...

But now I want to know is there any way to find divisbility with any prime number?

Suppose, how can I say 12783461236 is divisible with 97 or not?
 
Physics news on Phys.org
  • #2
Yes, there exist divisibility tests of that type for any number (not just primes), but in general they probably take more effort to use than simply dividing it by hand. The divisibility by 7 test hints at the way things get complicated...
 
  • #3
Originally posted by Moni
We've seen divisibility testing for different numbers...for 2,3,4,5,7,11...

But now I want to know is there any way to find divisbility with any prime number?

Suppose, how can I say 12783461236 is divisible with 97 or not?

Like:
Take the last digit, multiply by 29, subtract from the rest, and see if the result is divisible by 97?

It's probably faster to just trial divide.
 
  • #4
Actually I want to build a computer program...which can take any arbitrary size of 2 integers can tell larger one is divisible by the smaller one!

Can you give any link to proceed on?
 
  • #5
Arbitrary precision arithmetic is pretty straightforward.

Google on it for more information.
 
  • #6
Yes! I know, but I am going to develop a program myself :)

The google results I've got so far are with traditional division method, there is no use of such type of divisibility testing...

I want to develop one with this feature, then it will be faster than others available with stright forward DIVISION !
 
  • #7
Originally posted by Moni
Yes! I know, but I am going to develop a program myself :)

The google results I've got so far are with traditional division method, there is no use of such type of divisibility testing...

I want to develop one with this feature, then it will be faster than others available with stright forward DIVISION !

Observation 1:

The number of operations that you need for a 'traditional' division approach is [tex]log_2 m * log_2 n[/tex] where [tex]m,n[/tex] are the numbers that you're using. That's really fast already. So fast that checking numbers with thousands of digits should not take very long.

Are you trying to do some sort of crypto stuff?
 
  • #8
I just want to program myself with the use of Divisibility testing...

For traditional division I use:

void div(char *s1,char *s2,char *r,char *q)
{
char op1[SIZE],op2[SIZE],res[SIZE],factor[SIZE],x[SIZE],div[SIZE],z[SIZE];
int i,j,l1,l2,ok;
strcpy(op1,s1);
strcpy(op2,s2);
strcpy(res,"0");
strcpy(q,"0");
l1=strlen(op1);
l2=strlen(op2);
for(i=l1-l2;i>=0;--i)
{
strcpy(x,"1");
strcpy(div,"0");
for(j=1;j<=i;++j)
{
x[j]='0';
}
x[j]=0;
mul(op2,x,factor);
while(1)
{
ok=sub(op1,factor,z);
if(ok==-1)
{
strcpy(q,op1);
break;
}
else
{
strcpy(op1,z);
add(div,x,div);
}
}
add(res,div,res);
}
if(l1<l2) strcpy(q,s1);
strcpy(r,res);
}

It's not that crypto tech...just making math soft and learning algorithms :)
 

What is divisibility testing for prime numbers?

Divisibility testing for prime numbers is a method used to determine if a given number is a prime number. It involves checking if the number can be divided by any number other than 1 and itself without leaving a remainder.

Why is divisibility testing important in mathematics?

Divisibility testing is important in mathematics because it helps us identify prime numbers, which are the building blocks of all numbers. It also helps us in finding factors and multiples of numbers, which are important concepts in various mathematical operations.

What are the steps involved in divisibility testing for prime numbers?

The steps involved in divisibility testing for prime numbers are as follows: 1. Start with the number to be tested.2. Start dividing the number by 2. 3. If the number is divisible by 2, continue dividing by 2 until you get a remainder. 4. If the remainder is 0, the number is not a prime number. 5. If the remainder is not 0, move on to the next prime number (3, 5, 7, etc.) and repeat the process until you get a remainder. 6. If the remainder is 0 for any of these prime numbers, then the number is not a prime number. 7. If the remainder is not 0 for any of these prime numbers, then the number is a prime number.

What is the difference between divisibility testing and the Sieve of Eratosthenes?

Divisibility testing is a method used to determine if a given number is a prime number, while the Sieve of Eratosthenes is a method used to find all prime numbers up to a given number. Divisibility testing involves dividing a number by specific prime numbers, while the Sieve of Eratosthenes involves creating a list of all numbers and crossing out multiples of prime numbers to identify prime numbers.

How is divisibility testing used in real-life applications?

Divisibility testing is used in cryptography, which involves encoding and decoding secret messages. It is also used in computing, specifically in algorithms that involve finding prime numbers. Additionally, divisibility testing is used in fields such as finance, statistics, and data analysis. It is also used in everyday tasks like checking if a number is divisible by 2 to determine if it is even or odd.

Similar threads

  • Linear and Abstract Algebra
Replies
4
Views
1K
  • General Math
2
Replies
47
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
7
Views
839
  • Linear and Abstract Algebra
Replies
1
Views
578
  • Precalculus Mathematics Homework Help
Replies
12
Views
1K
  • Linear and Abstract Algebra
Replies
11
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
725
  • Programming and Computer Science
Replies
22
Views
729
  • General Math
Replies
7
Views
1K
Back
Top