gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
Given an int variable n already declared and initialized. Write a code snippet that…
- User
Given an int variable n already declared and initialized. Write a code snippet that prints integer values until n. Your code snippet should only print values that are both multiples of 3, and end in 1. Hint: use the module operator % to retrieve the unit number. write in java with no comments
- Assistant
for (int i = 1; i <= n; i++) { if (i % 3 == 0 && i % 10 == 1) { System.out.println(i); } }