Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 31st, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Test {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         int a1 = Integer.parseInt(input.nextLine());
  10.         int d = Integer.parseInt(input.nextLine());
  11.         int searchedElement = Integer.parseInt(input.nextLine());
  12.  
  13.         int nCounter = 0;
  14.         int sum = 0;
  15.         int m = 0;
  16.         String firstNumber = String.valueOf(a1);
  17.         for (int i = a1; i <= searchedElement; i = i + d) {
  18.             nCounter++;
  19.             if (i < searchedElement) {
  20.                 sum += i;
  21.             }
  22.             if(nCounter >= 2) {
  23.                 String currentNum = String.valueOf(i);
  24.                 for (int j = 0; j < currentNum.length(); j++) {
  25.                     String currentChar = String.valueOf(currentNum.charAt(j));
  26.                     if (firstNumber.contains(currentChar)) {
  27.                         m++;
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.         System.out.printf("n = %d, S = %d, m = %d",nCounter,sum,m);
  33.  
  34.  
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top