Algorithm Analysis
Print odd numbers less than , starting from 1, in ascending order.
Implementation of the algorithm
Read the input value .
scanf("%d", &n);
Print odd numbers less than , starting from 1, in ascending order.
for (i = 1; i < n; i += 2) printf("%d ", i);
Java implementation
import java.util.*; class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); int n = con.nextInt(); for (int i = 1; i < n; i += 2) System.out.print(i + " "); System.out.println(); con.close(); } }
Python implementation
n = int(input()) for i in range(1, n, 2): print(i, end = " ") print()