July 26, 2021
def solution(n):
answer = 0
idx = 1
while (idx <= n):
sum = 0
for i in range(idx, n + 1):
sum += i
if sum == n:
answer += 1
idx += 1
break
elif sum > n:
idx += 1
break
return answer
def expressions(num):
return len([i for i in range(1,num+1,2) if num % i is 0])
class Solution {
public int solution(int n) {
int answer = 0;
int left = 1;
int right = 1;
int sum = 1;
while (right <= n) {
if (sum == n) {
answer++;
right++;
sum += right;
} else if (sum < n) {
right++;
sum += right;
} else if (sum > n) {
sum -= left;
left++;
}
}
return answer;
}
}