Sum = 1 + 12 + 123 + 1234 + 12345 + ā€¦ + 1234567891011ā€¦n how to sum%10007 mod answer | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
- 3

Sum = 1 + 12 + 123 + 1234 + 12345 + ā€¦ + 1234567891011ā€¦n how to sum%10007 mod answer

test input 2 output 13

19th Jul 2017, 12:12 PM
Ilyos Yuldoshev
Ilyos Yuldoshev - avatar
11 Respostas
+ 4
thanks
6th Aug 2017, 6:01 PM
Ilyos Yuldoshev
Ilyos Yuldoshev - avatar
+ 4
You are welcome!
6th Aug 2017, 6:01 PM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 3
no input 3 output sum = 1+12+123=136%10007
28th Jul 2017, 3:49 AM
Ilyos Yuldoshev
Ilyos Yuldoshev - avatar
+ 1
importĀ java.util.Scanner; public classĀ SeriesĀ  { Ā public static voidĀ main(String args[])Ā  Ā { Ā  Scanner sc =Ā newĀ Scanner(System.in); Ā  System.out.print("Enter the number of terms: "); Ā Ā intĀ n = sc.nextInt(); Ā Ā intĀ s = 0, c; Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā Ā // s for terms of series, c for counter to generate n terms Ā Ā forĀ (c = 1; c <= n; c++) { Ā  Ā s = s * 10 + c; Ā  Ā System.out.print(s + " "); Ā  } Ā } } Output: Enter the number of terms: 6 1, Ā 12, Ā 123, Ā 1234, Ā 12345, Ā 123456....... You just need to add up!šŸ˜ø
19th Jul 2017, 7:26 AM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 1
Here you go. Sorry for the functions https://code.sololearn.com/cK6EYzD4k9ub/?ref=app
19th Jul 2017, 7:59 AM
Limitless
Limitless - avatar
+ 1
I'm confused, please elaborate
19th Jul 2017, 12:18 PM
Limitless
Limitless - avatar
19th Jul 2017, 12:28 PM
James
James - avatar
+ 1
Just add %10007 Easy! I'll update my code right away.
28th Jul 2017, 5:43 AM
James
James - avatar
+ 1
public class series { public static void main(String args[]) { int i,s=0; for(i=1;i<=9;i++) { s+=(s*10+1); } System.out.println("The sum of the series:"+s); } }
1st Aug 2019, 2:45 PM
Aniket Bhattacharjee
0
Can you say it in java that works on blue j
24th Oct 2021, 5:23 AM
Ayan Sunil
0
The general term satisfies the recurrence relation a(k) = 10a(k-1) + k with a(1) = 1. You can solve for it by back-substituting in the previous terms and you should get a(k) = (10^(k+1) - 9k - 10)/81. Summing from k = 1 to k = n gives you the result you need, s(n) = (100(100^n - 1))/729 - (n(n+1))/18 - (10n)/81. This is faster than calculating through a loop. Just ask for the input of n, plug it into the formula, and print the output of s(n).
21st Aug 2022, 4:28 PM
Michael David
Michael David - avatar