Skip to main content
added 32 characters in body
Source Link

The Challenge

In as few characters as possible, find the value of i^n\$i^n\$, given n\$n\$, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, i\$i\$ is defined such that i^2=-1\$i^2=-1\$. So:

  • i^1=i\$i^1=i\$
  • i^2=-1\$i^2=-1\$
  • i^3=-i\$i^3=-i\$
  • i^4=1\$i^4=1\$

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

The Challenge

In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, i is defined such that i^2=-1. So:

  • i^1=i
  • i^2=-1
  • i^3=-i
  • i^4=1

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

The Challenge

In as few characters as possible, find the value of \$i^n\$, given \$n\$, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, \$i\$ is defined such that \$i^2=-1\$. So:

  • \$i^1=i\$
  • \$i^2=-1\$
  • \$i^3=-i\$
  • \$i^4=1\$

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

Tweeted twitter.com/#!/StackCodeGolf/status/537850756289003521
edited tags
Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
added 3 characters in body
Source Link
Kezz
  • 445
  • 4
  • 7

The Challenge

In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, i is the square root of defined such that i^2=-1. So:

  • i^1=i
  • i^2=-1
  • i^3=-i
  • i^4=1

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

The Challenge

In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, i is the square root of -1. So:

  • i^1=i
  • i^2=-1
  • i^3=-i
  • i^4=1

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

The Challenge

In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String.

For those that don't know, i is defined such that i^2=-1. So:

  • i^1=i
  • i^2=-1
  • i^3=-i
  • i^4=1

This then repeats..

Rules

  • If your language supports complex numbers, don't use any functions or arithmetic that could work this out.
  • Floating point inaccuracies are fine for answers that would return decimals anyway, but integer inputs should give exact results

Bonus Points

-5 if you can work the value out where n is also negative

-15 if you can work out the value for any real number (this bonus includes the -5 from the above bonus)

Good luck!

formatting and rule addition
Source Link
Kezz
  • 445
  • 4
  • 7
Loading
deleted 29 characters in body; added 38 characters in body
Source Link
Kezz
  • 445
  • 4
  • 7
Loading
Source Link
Kezz
  • 445
  • 4
  • 7
Loading