Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
449 B
1
Indexable
Never
/**
 * prints set of numbers with for and while loops
 *
 * @author Amanda Cui
 * @version 11/14/23
 */
public class NestedPractice3{
    public static void main(String[] args){
        int i=1;
        int sum=0;
        while(i<=100){
            for(int k=1;k<=i;k++){
                sum+=i;
            }
            i++;
            System.out.println("The sum of positive integers from 1 to "+i+"is "+sum);
        }
    }
}
Leave a Comment