Divisibility Testing for Prime Numbers

  • Context: Undergrad 
  • Thread starter Thread starter Moni
  • Start date Start date
  • Tags Tags
    Divisibility Testing
Click For Summary

Discussion Overview

The discussion revolves around the topic of divisibility testing for prime numbers and the development of algorithms or programs to determine divisibility. Participants explore various methods and considerations related to implementing such tests, particularly for large integers.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about methods for testing divisibility by any prime number, specifically asking how to determine if 12783461236 is divisible by 97.
  • Another participant suggests that while divisibility tests exist for any number, they may be more complex than simple division.
  • A proposed method involves manipulating the last digit of a number and checking the result for divisibility, though it is noted that trial division might be faster.
  • One participant expresses a desire to create a computer program that can determine if one large integer is divisible by another, seeking guidance on how to proceed.
  • Another participant mentions that arbitrary precision arithmetic is straightforward and suggests looking it up for more information.
  • One participant emphasizes their intention to develop a program that utilizes divisibility testing rather than traditional division methods, aiming for improved efficiency.
  • Concerns are raised about the efficiency of traditional division methods, with one participant noting that the number of operations required is logarithmic and thus quite fast for large numbers.
  • A participant shares a code snippet for traditional division, clarifying that their project is focused on mathematical software and learning algorithms rather than cryptographic applications.

Areas of Agreement / Disagreement

Participants express varying opinions on the complexity and efficiency of different divisibility testing methods. There is no consensus on a specific approach or method, and the discussion remains open-ended regarding the best practices for implementing divisibility tests.

Contextual Notes

Participants mention the potential complexity of divisibility tests for primes and the efficiency of traditional division methods, but do not resolve the specifics of these methods or their comparative effectiveness.

Moni
Messages
178
Reaction score
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
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...
 
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.
 
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?
 
Arbitrary precision arithmetic is pretty straightforward.

Google on it for more information.
 
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 !
 
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?
 
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 :)
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 47 ·
2
Replies
47
Views
7K
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K