H(n) = 30 if n = 1; H(n) = H(n-1) + 5n + 10 if n > 1. Write a recursive method with signature “public static int H(int n)” that computes the n-th number of the sequence.

0.0(0)
Studied by 1 person
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/4

flashcard set

Earn XP

Last updated 6:18 PM on 10/6/22
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

5 Terms

1
New cards
L1: public class Main {
AFTER THIS
public static int H(int n) {
2
New cards
L2: if(n == 1) {
L2: return 30;
}
3
New cards
L3: else {
return H(n-1) + THEN
L4: 5*n + 10;
}
}
4
New cards
L5: public static void main (String args[]) { THEN
L6: System.out.println("H(1): " + H(1));
5
New cards
L7: System.out.println("H(2): " + H(2));

L8: System.out.println("H(5): " + H(5));
}
}