Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Question

Commonmark migration
Source Link

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.
Tweeted twitter.com/#!/StackCodeGolf/status/466423981126733824

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources or, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources or math libraries. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources, math libraries or built-in functions for factorization or GCD. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.
Clarified rule that I thought was clear in the example, but writing it explicitly now
Source Link
durron597
  • 4.8k
  • 1
  • 22
  • 49

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

SpaceSingle space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources or math libraries. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Space delimited with exponents. Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources or math libraries. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.

Title says it all. Two input 32-bit positive integers m, n >= 2, output gcd(m,n) in prime factorization form.

##Input

Command line args or 1 line of stdin okay, whatever's better for golf.

Output

Single space delimited with exponents (no additional spaces). Output nothing if the inputs are relatively prime.

Examples:

$ ./factorize 96 162
2^1 3^1
$ ./factorize 14 15
$ ./factorize 196 294
2^1 7^2

Rules

  • You may not use external resources or math libraries. Examples: Java, no java.lang.Math. ruby, no prime_division, perl, no factor, etc.
Added relatively prime case
Source Link
durron597
  • 4.8k
  • 1
  • 22
  • 49
Loading
added 2 characters in body
Source Link
durron597
  • 4.8k
  • 1
  • 22
  • 49
Loading
Source Link
durron597
  • 4.8k
  • 1
  • 22
  • 49
Loading

AltStyle によって変換されたページ (->オリジナル) /