Skip to content

Commit

Permalink
[feat] 2桁までのListを表示
Browse files Browse the repository at this point in the history
  • Loading branch information
mrs1669 committed May 15, 2024
1 parent f8dbd3e commit 17aaf52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions PrimePickApp/QuizData/PrimeData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import Foundation

final class PrimeData {
func generateOneOrTwoDigitPrimes() -> [Int] {
init() {}

public func generateOneOrTwoDigitPrimes() -> [Int] {
var twoDigitPrimes = [Int]()
outerLoop: for num in 1..<100 {
outerLoop: for num in 3..<100 {
for i in 2..<num {
if num % i == 0 {
continue outerLoop
Expand Down
11 changes: 10 additions & 1 deletion PrimePickApp/QuizView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
import SwiftUI

struct QuizView: View {
let primeData = PrimeData()
var primes: [Int]
init() {
primes = primeData.generateOneOrTwoDigitPrimes()
}

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
List(primes, id: \.self) { prime in
Text("\(prime)")
}
.navigationTitle("Primes")
}
}

Expand Down

0 comments on commit 17aaf52

Please # to comment.