Count numbers up to N that cannot be expressed as sum of at least two consecutive positive integers | Java program for the above approach ; Function to count numbers that cannot be expressed as sum of two or more consecutive + ve integers ; Stores the count of such numbers ; Driver Code
import java . io . * ; import java . lang . * ; import java . util . * ; public class GFG { static void countNum ( int N ) { int ans = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) + 1 ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 100 ; countNum ( N ) ; } }