LoginSignup
0
0

More than 1 year has passed since last update.

Codewars Perimeter of squares in a rectangle

Posted at

import java.math.BigInteger;
public class SumFct {
	public static BigInteger perimeter(BigInteger n) {
        BigInteger[] arr = new BigInteger[n.intValue() + 1];

        arr[0] = BigInteger.ONE;
        arr[1] = BigInteger.ONE;
        BigInteger temp = BigInteger.ONE.add(BigInteger.ONE);
        for (int i = 2; i <= n.intValue(); i++) {
            arr[i] = arr[i - 1].add(arr[i - 2]);
            temp = temp.add(arr[i]);
        }

        return temp.multiply(BigInteger.valueOf(4L));
    
	}
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0