subject
Mathematics, 14.02.2020 16:30 camiilajakobsen1400

Write a recursive method called printNumPattern() to output the following number pattern.

Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached.

Ex. If the input is

12
3
the output is

12 9 6 3 0 3 6 9 12
Code Below:

import java. util. Scanner;

public class NumberPattern {
// TODO: Write recursive printNumPattern() method

public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int num1;
int num2;

num1 = scnr. nextInt();
num2 = scnr. nextInt();
printNumPattern(num1, num2);

ansver
Answers: 3

Other questions on the subject: Mathematics

image
Mathematics, 21.06.2019 14:30, bwelsh880
Apple pie is removed from 350 degree oven. temperature of the pie t minutes after being removed id given by the function t(t)=72+268e-0.068t
Answers: 1
image
Mathematics, 21.06.2019 18:30, Lilshawn1
Sasha drank 8 bottles of water everyday for a week. how many bottles of water did she drink in total?
Answers: 2
image
Mathematics, 21.06.2019 23:30, medusa36
Solve the following: 12(x^2–x–1)+13(x^2–x–1)=25(x^2–x–1) 364x–64x=300x
Answers: 1
image
Mathematics, 22.06.2019 03:10, erinleyanne
If f(x) = 5х – 2 and g(x) = 2х + 1, find (f – g)(x).
Answers: 1
You know the right answer?
Write a recursive method called printNumPattern() to output the following number pattern.

Questions in other subjects:

Konu
Mathematics, 12.11.2020 17:50
Konu
Mathematics, 12.11.2020 17:50
Konu
Business, 12.11.2020 17:50