Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (16.27 KB, 2 trang )
Bài Tập Vòng Lặp JAVA
1.
Write a program that has one parameter that specifies an integer n and prints n copies of 1,
followed on the next line by n-1 copies of 2, followed on the next line by n-2 copies of 3, …
with the last line printing one n. You may assume n is positive. As an example, printN(6)
would result in the following output:
111111
22222
3333
444
55
6
2.
3.
2. Write an algorithm to accept a number between 1 and 9 and display a pattern. For
example, if the number entered is 5, the following pattern should be displayed:
1
21
321
4321
54321
Write a program to read an integer number (n>0). Write flowing methods:
- Checking whether the input number is a prime number or n
- Print out prime submultiples of number n
- Generate the first 100 prime numbers.
4. Write a program to read an integer number (n>0). Write following methods: