Category "integer"

Given a sequence of integers, return the sum of all the integers that have an even index, multiplied by the integer at the last index

This is my solution and it passes some of the tests, but not all of them. Can anyone help me and explain why? Thank you :) function evenLast(numbers) { let su

Is it possible to distinguish Bool and Int in Swift?

I have an AnyObject type that can be String, Int or Bool type. I need to distinguish them. This code tries to do so, but it considers Bool to be Int: import C

Is it possible to distinguish Bool and Int in Swift?

I have an AnyObject type that can be String, Int or Bool type. I need to distinguish them. This code tries to do so, but it considers Bool to be Int: import C

Swift: Check which value in NSArray is closest to another given value

Lets say I have an array var values:[CGFloat] = [-12.0, 450, 300] I need to find out which of these numbers is closest to a given value, say var givenValue

How to separate range of integers into two equal parts

I have an array of integers like this one int [] num = {5, 8, 1, 1, 2, 3, 2} and I want to divide it into 2 parts, so that the total of 2 sets will be as equ

Integer division in Python

I'm confused about the following integer math in python: -7/3 = -3 since (-3)*3 = -9 < -7. I understand. 7/-3 = -3 I don't get how this is defined. (-3)*(-

What is the difference between “int” and “uint” / “long” and “ulong”?

I know about int and long (32-bit and 64-bit numbers), but what are uint and ulong?

Converting a string to an integer on Android

How do I convert a string into an integer? I have a textbox I have the user enter a number into: EditText et = (EditText) findViewById(R.id.entry1); String he