Created
January 23, 2022 08:43
-
-
Save AnasAboreeda/6b23787a3d6cdc4ed024f23ccc325d19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NestedLoop { | |
public static void main(String[] args) { | |
int n = 10; // 1 step --> Note: n can be anything. This is just an example | |
int sum = 0; // 1 step | |
double pie = 3.14; // 1 step | |
for (int var = 0; var < n; var = var + 3) { // n/3 steps | |
System.out.println("Pie: " + pie); // n/3 steps | |
for (int j = 0; j < n; j = j + 2) { // (n/3 * n/2) steps | |
sum++; // (n/3 * n/2) steps | |
System.out.println("Sum = " + sum); // (n/3 * n/2) steps | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment