Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const partition = N => {
- for (let i = 1; i <= Math.sqrt(N); i++) {
- if (isPrime(i) && N % i == 0) {
- return [i, N / i];
- }
- }
- };
- const isPrime = n => {
- if (n <= 1) {
- return false;
- }
- for (let i = 2; i < n; i++) {
- if (n % i == 0) {
- return false;
- }
- }
- return true;
- };
- const gcd = (a, b) => {
- if (!b) {
- return a;
- }
- return gcd(b, a % b);
- };
- const e = 127;
- const N = 1643;
- const parts = partition(1643);
- const phi = (parts[0] - 1) * (parts[1] - 1);
- for (let i = 1; i <= phi; i++) {
- if ((i * e) % phi == 1) {
- console.log(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement