Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void create_PrimNumbers(out BigInteger first, out BigInteger second)
- {
- Random zufall = new Random();
- bool is_prim = true;
- for (; ; )
- {
- is_prim = true;
- BigInteger temp = zufall.Next(2, 100);
- if (temp > 1)
- {
- // natürlich(BigInteger), insgesamt nur 2 natürliche Zahlen als Teiler(sich selbst und 1)
- // prim > 1
- for (BigInteger i = 2; i < temp; i++)
- {
- if (temp % i == 0)
- {
- is_prim = false;
- }
- }
- if (is_prim == true)
- {
- first = temp;
- break;
- }
- }
- }
- for (; ; )
- {
- is_prim = true;
- BigInteger temp = zufall.Next(2, 100);
- if (temp > 1)
- {
- // natürlich(BigInteger), insgesamt nur 2 natürliche Zahlen als Teiler(sich selbst und 1)
- // prim > 1
- for (BigInteger i = 2; i < temp; i++)
- {
- if (temp % i == 0)
- {
- is_prim = false;
- }
- }
- if (is_prim == true && first != temp)
- {
- second = temp;
- break;
- }
- }
- }
- }
- public bool check_relativelyPrime(BigInteger zahlA, BigInteger zahlB)
- {
- bool relativePrime = true;
- BigInteger index = zahlA;
- // Check which one is greater and set tiniest as index
- /* if (zahlA > zahlB)
- {
- index = zahlB;
- } Rechenzeit Ersparnis, da Parameter schon in richtiger Reihenfolge reinkommen */
- // Check for every number until index
- // if there is a number which divides both naturally
- for (BigInteger i = 2; i <= index; i++)
- {
- if ((zahlA % i == 0) && (zahlB % i == 0))
- {
- relativePrime = false;
- break;
- }
- }
- return relativePrime;
- }
Advertisement
Add Comment
Please, Sign In to add comment